From d6b43e11757a47c6f6b5411a8b88dfe434643f43 Mon Sep 17 00:00:00 2001 From: schwarze Date: Wed, 7 May 2014 16:18:57 +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). --- usr.bin/mandoc/mandocdb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c index a46a3e3a5ed..ee4f12f4e05 100644 --- a/usr.bin/mandoc/mandocdb.c +++ b/usr.bin/mandoc/mandocdb.c @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.104 2014/05/07 15:10:33 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.105 2014/05/07 16:18:57 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze @@ -2028,13 +2028,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.20.1