From 5c195601f70dee7550a601ff2db5bdda18b6ba83 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Wed, 7 May 2014 16:19:03 +0000 Subject: [PATCH] Render roff escape sequences contained in manual page descriptions before putting them into the mpages table. Issue found by bentley@ in OpenBSD::Getopt(3p). --- mandocdb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mandocdb.c b/mandocdb.c index 85f0cca0..05530fb0 100644 --- a/mandocdb.c +++ b/mandocdb.c @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.147 2014/05/07 15:10:36 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.148 2014/05/07 16:19:03 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze @@ -2036,13 +2036,22 @@ dbadd(struct mpage *mpage, struct mchars *mc) if (debug) say(mlink->file, "Adding to database"); + i = strlen(mpage->desc) + 1; + key = mandoc_calloc(1, sizeof(struct str) + i); + memcpy(key->key, mpage->desc, i); + render_key(mc, key); + i = 1; - SQL_BIND_TEXT(stmts[STMT_INSERT_PAGE], i, mpage->desc); + SQL_BIND_TEXT(stmts[STMT_INSERT_PAGE], i, key->rendered); SQL_BIND_INT(stmts[STMT_INSERT_PAGE], i, FORM_SRC == mpage->form); SQL_STEP(stmts[STMT_INSERT_PAGE]); mpage->pageid = sqlite3_last_insert_rowid(db); sqlite3_reset(stmts[STMT_INSERT_PAGE]); + if (key->rendered != key->key) + free(key->rendered); + free(key); + while (NULL != mlink) { dbadd_mlink(mlink); mlink = mlink->next; -- 2.47.1