diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-01-12 18:02:20 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-01-12 18:02:20 +0000 |
commit | 118689aa2e6ecb08ee82301bd70a70d41d1fea96 (patch) | |
tree | 4797311def1c3e497d16ad0fe1864afe2a67d1f5 /roff.c | |
parent | 4fdc8558c5d198e182cb2f69447d3a16f5f8bbb2 (diff) | |
download | mandoc-118689aa2e6ecb08ee82301bd70a70d41d1fea96.tar.gz mandoc-118689aa2e6ecb08ee82301bd70a70d41d1fea96.tar.zst mandoc-118689aa2e6ecb08ee82301bd70a70d41d1fea96.zip |
Skipping all escape sequences at the beginning of strings in deroff()
was too aggressive. There are strings that legitimately begin with
an escape sequence. Only skip leading escape sequences representing
whitespace.
Bug reported by martijn@.
Diffstat (limited to 'roff.c')
-rw-r--r-- | roff.c | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.287 2017/01/10 21:59:47 schwarze Exp $ */ +/* $Id: roff.c,v 1.288 2017/01/12 18:02:20 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -1223,16 +1223,12 @@ deroff(char **dest, const struct roff_node *n) return; } - /* Skip leading whitespace and escape sequences. */ + /* Skip leading whitespace. */ - cp = n->string; - while (*cp != '\0') { - if ('\\' == *cp) { - cp++; - mandoc_escape((const char **)&cp, NULL, NULL); - } else if (isspace((unsigned char)*cp)) + for (cp = n->string; *cp != '\0'; cp++) { + if (cp[0] == '\\' && strchr(" %&0^|~", cp[1]) != NULL) cp++; - else + else if ( ! isspace((unsigned char)*cp)) break; } |