summaryrefslogtreecommitdiffstats
path: root/mdoc_macro.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-05-07 05:39:35 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-05-07 05:39:35 +0000
commitbf3378829e6debee09473d5e9f1e45d20082ceae (patch)
treeab662fed4d9250d6fb1edfe7eabbeaac3fd79336 /mdoc_macro.c
parentc78f5a1f78e5222eed678f27a57137e97b3554ec (diff)
downloadmandoc-bf3378829e6debee09473d5e9f1e45d20082ceae.tar.gz
Protection against running lookup() against quoted words.
Diffstat (limited to 'mdoc_macro.c')
-rw-r--r--mdoc_macro.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/mdoc_macro.c b/mdoc_macro.c
index 0652af14..b88143c7 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -702,19 +702,22 @@ blk_exp_close(MACRO_PROT_ARGS)
if (ARGS_EOLN == ac)
break;
- if (MDOC_MAX != (ntok = lookup(tok, p))) {
- if ( ! flushed) {
- if ( ! rew_sub(MDOC_BLOCK, m, tok, line, ppos))
- return(0);
- flushed = 1;
- }
- if ( ! mdoc_macro(m, ntok, line, lastarg, pos, buf))
+ ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p);
+
+ if (MDOC_MAX == ntok) {
+ if ( ! mdoc_word_alloc(m, line, lastarg, p))
return(0);
- break;
- }
+ continue;
+ }
- if ( ! mdoc_word_alloc(m, line, lastarg, p))
+ if ( ! flushed) {
+ if ( ! rew_sub(MDOC_BLOCK, m, tok, line, ppos))
+ return(0);
+ flushed = 1;
+ }
+ if ( ! mdoc_macro(m, ntok, line, lastarg, pos, buf))
return(0);
+ break;
}
if ( ! flushed && ! rew_sub(MDOC_BLOCK, m, tok, line, ppos))
@@ -787,8 +790,6 @@ in_line(MACRO_PROT_ARGS)
if (ARGS_PUNCT == ac)
break;
- /* Quoted words shouldn't be looked-up. */
-
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p);
/*
@@ -985,7 +986,9 @@ blk_full(MACRO_PROT_ARGS)
continue;
}
- if (MDOC_MAX == (ntok = lookup(tok, p))) {
+ ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p);
+
+ if (MDOC_MAX == ntok) {
if ( ! mdoc_word_alloc(m, line, la, p))
return(0);
continue;
@@ -1101,7 +1104,9 @@ blk_part_imp(MACRO_PROT_ARGS)
body = m->last;
}
- if (MDOC_MAX == (ntok = lookup(tok, p))) {
+ ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p);
+
+ if (MDOC_MAX == ntok) {
if ( ! mdoc_word_alloc(m, line, la, p))
return(0);
continue;
@@ -1223,7 +1228,9 @@ blk_part_exp(MACRO_PROT_ARGS)
assert(NULL != head && NULL != body);
- if (MDOC_MAX == (ntok = lookup(tok, p))) {
+ ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p);
+
+ if (MDOC_MAX == ntok) {
if ( ! mdoc_word_alloc(m, line, la, p))
return(0);
continue;
@@ -1339,7 +1346,9 @@ in_line_argn(MACRO_PROT_ARGS)
flushed = 1;
}
- if (MDOC_MAX != (ntok = lookup(tok, p))) {
+ ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p);
+
+ if (MDOC_MAX != ntok) {
if ( ! flushed && ! rew_elem(m, tok))
return(0);
flushed = 1;