diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-12-27 21:44:31 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-12-27 21:44:31 +0000 |
commit | efa3d844eb71b913d9b6f80b1172d1aa1d0dcb37 (patch) | |
tree | 3ceb1ee1b0f56fc22bd62c1e7c59a0935e4187be | |
parent | e3253b89da3e00446fc84281131ed872b9743382 (diff) |
In case an ID attribute is written in pieces, only protect the first
piece with a prepended 'x', not each piece, such that quoted and
unquoted .Sh, .Ss, and .Sx arguments are compatible with each other.
Fixing a bug reported by Nicolas Joly <njoly at NetBSD dot org>,
avoiding a regression in my first patch as pointed out by njoly as well.
"feel free to do so" kristaps@
-rw-r--r-- | usr.bin/mandoc/html.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/usr.bin/mandoc/html.c b/usr.bin/mandoc/html.c index 2aa4f4bb107..ebf6d06d16c 100644 --- a/usr.bin/mandoc/html.c +++ b/usr.bin/mandoc/html.c @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.20 2010/12/25 13:23:03 schwarze Exp $ */ +/* $Id: html.c,v 1.21 2010/12/27 21:44:30 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -767,20 +767,24 @@ html_idcat(char *dst, const char *src, int sz) { int ssz; - assert(sz); + assert(sz > 2); /* Cf. <http://www.w3.org/TR/html4/types.html#h-6.2>. */ - for ( ; *dst != '\0' && sz; dst++, sz--) - /* Jump to end. */ ; - - assert(sz > 2); - /* We can't start with a number (bah). */ - *dst++ = 'x'; - *dst = '\0'; - sz--; + if ('#' == *dst) { + dst++; + sz--; + } + if ('\0' == *dst) { + *dst++ = 'x'; + *dst = '\0'; + sz--; + } + + for ( ; *dst != '\0' && sz; dst++, sz--) + /* Jump to end. */ ; for ( ; *src != '\0' && sz > 1; src++) { ssz = snprintf(dst, (size_t)sz, "%.2x", *src); |