diff --git a/ChangeLog b/ChangeLog index 71be3927..8a6aa28b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Nov 23 17:22:03 CET 2006 Daniel Veillard + + * HTMLparser.c: applied patch from Steven Rainwater to fix + UTF8ToHtml behaviour on code points which are not mappable to + predefined HTML entities, fixes #377544 + Thu Nov 23 17:11:23 CET 2006 Daniel Veillard * xpath.c: fixed a bug where the principal node type of an axis diff --git a/HTMLparser.c b/HTMLparser.c index 0a5aae91..5f02578b 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -1842,6 +1842,8 @@ UTF8ToHtml(unsigned char* out, int *outlen, } else { int len; const htmlEntityDesc * ent; + const char *cp; + char nbuf[16]; /* * Try to lookup a predefined HTML entity for it @@ -1849,16 +1851,16 @@ UTF8ToHtml(unsigned char* out, int *outlen, ent = htmlEntityValueLookup(c); if (ent == NULL) { - /* no chance for this in Ascii */ - *outlen = out - outstart; - *inlen = processed - instart; - return(-2); + snprintf(nbuf, sizeof(nbuf), "#%u", c); + cp = nbuf; } - len = strlen(ent->name); + else + cp = ent->name; + len = strlen(cp); if (out + 2 + len >= outend) break; *out++ = '&'; - memcpy(out, ent->name, len); + memcpy(out, cp, len); out += len; *out++ = ';'; }