summaryrefslogtreecommitdiffstats
path: root/roff.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-01-12 18:02:20 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-01-12 18:02:20 +0000
commit5f8f5dd2e0219fb9c5733ffe933ead27619e6d99 (patch)
treee87f8b85cc5fb5a09b7b22df80f1a5cff0847030 /roff.c
parent59750b8006bff16f8ef5203be593021f8301edb3 (diff)
downloadmandoc-5f8f5dd2e0219fb9c5733ffe933ead27619e6d99.tar.gz
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.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/roff.c b/roff.c
index 8a9e49e9..542272ba 100644
--- a/roff.c
+++ b/roff.c
@@ -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;
}