From 80d135a1892a95ceee21b877bd6b74b3219985d8 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 28 Jul 2009 20:44:17 +0400 Subject: [PATCH] * Fix entitles decoding for hex and oct characters --- src/html.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/html.c b/src/html.c index 363512df1..8f5664079 100644 --- a/src/html.c +++ b/src/html.c @@ -265,15 +265,17 @@ decode_entitles (char *s) { char *t = s; /* t - tortoise */ char *h = s; /* h - hare */ + char *e = s; char *end_ptr; - int state = 0, val; + int state = 0, val, base; while (*h) { switch (state) { /* Out of entitle */ case 0: if (*h == '&' && *(h + 1) == '#') { - state = 1; + state = 1; + e = h; h ++; continue; } @@ -285,9 +287,24 @@ decode_entitles (char *s) break; case 1: if (*h == ';') { - val = strtoul ((t + 2), &end_ptr, 10); + /* Determine base */ + if (*(e + 2) == 'x' || *(e + 2) == 'X') { + base = 16; + } + else if (*(e + 2) == 'o' || *(e + 2) == 'O') { + base = 8; + } + else { + base = 10; + } + if (base == 10) { + val = strtoul ((e + 2), &end_ptr, base); + } + else { + val = strtoul ((e + 3), &end_ptr, base); + } if ((end_ptr != NULL && *end_ptr != ';') || !g_ascii_isalnum ((char)val)) { - msg_info ("decode_entitles: invalid entitle code, cannot convert, strtoul returned %d", val); + msg_info ("decode_entitles: invalid entitle code, cannot convert, strtoul returned %d, while reading %s", val, end_ptr); /* Skip undecoded */ t = h; } -- 2.39.5