diff options
Diffstat (limited to 'html.c')
-rw-r--r-- | html.c | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -771,20 +771,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); |