Skip to content

Commit

Permalink
lib-mail: Support decimal/hexadecimal encoded entities
Browse files Browse the repository at this point in the history
Add support for &#nnn; and &#xnnn; entities.
  • Loading branch information
cmouse authored and sirainen committed Oct 25, 2016
1 parent 1165c4b commit 3729762
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/lib-mail/mail-html2text.c
Expand Up @@ -118,14 +118,26 @@ parse_tag_name(struct mail_html2text *ht,

static bool html_entity_get_unichar(const char *name, unichar_t *chr_r)
{
unsigned int i;
unichar_t chr;

for (i = 0; i < N_ELEMENTS(html_entities); i++) {
for (size_t i = 0; i < N_ELEMENTS(html_entities); i++) {
if (strcasecmp(html_entities[i].name, name) == 0) {
*chr_r = html_entities[i].chr;
return TRUE;
}
}

/* maybe it's just encoded binary byte
it can be &#nnn; or &#xnnn;
*/
if (name[0] == '#' &&
((name[1] == 'x' &&
str_to_uint32_hex(name+2, &chr) == 0) ||
str_to_uint32(name+1, &chr) == 0)) {
*chr_r = chr;
return TRUE;
}

return FALSE;
}

Expand Down

0 comments on commit 3729762

Please sign in to comment.