From 118689aa2e6ecb08ee82301bd70a70d41d1fea96 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Thu, 12 Jan 2017 18:02:20 +0000 Subject: 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@. --- roff.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'roff.c') diff --git a/roff.c b/roff.c index 6b736bec..966ed9d5 100644 --- a/roff.c +++ b/roff.c @@ -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 * Copyright (c) 2010-2015, 2017 Ingo Schwarze @@ -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; } -- cgit v1.2.3-56-ge451