summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2017-01-12 18:02:25 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2017-01-12 18:02:25 +0000
commit1392b50d062cb927b3ff62380856ed0edc29540c (patch)
treee47345184eec09f6ec80ae9e6228f37f1ed01657 /usr.bin/mandoc
parentd5cb61559f3b3666c4eed3fcc63a08b0e37bb44c (diff)
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 'usr.bin/mandoc')
-rw-r--r--usr.bin/mandoc/roff.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index 54a0f8994a8..3bb4fe4c45d 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.c,v 1.159 2017/01/10 21:54:34 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.160 2017/01/12 18:02:24 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -1221,16 +1221,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;
}