changeset 21794:8f82dc5e0b76

Patch #3848 from Eion Robb: "purple_markup_unescape_entity doesn't escape hexadecimal references", with changes from QuLogic. Closes #3848.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 06 Dec 2007 12:26:40 +0000
parents f215729af7a7
children 8c16f5900674 5417c26b5ecc
files COPYRIGHT libpurple/util.c
diffstat 2 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Thu Dec 06 09:54:04 2007 +0000
+++ b/COPYRIGHT	Thu Dec 06 12:26:40 2007 +0000
@@ -309,6 +309,7 @@
 Tim Ringenbach
 Dennis Ristuccia
 Lee Roach
+Eion Robb
 Rhett Robinson
 Luciano Miguel Ferreira Rocha
 Andrew Rodland
--- a/libpurple/util.c	Thu Dec 06 09:54:04 2007 +0000
+++ b/libpurple/util.c	Thu Dec 06 12:26:40 2007 +0000
@@ -921,6 +921,7 @@
 {
 	const char *pln;
 	int len, pound;
+	char temp[2];
 
 	if (!text || *text != '&')
 		return NULL;
@@ -943,8 +944,9 @@
 		pln = "\302\256";      /* or use g_unichar_to_utf8(0xae); */
 	else if(IS_ENTITY("&apos;"))
 		pln = "\'";
-	else if(*(text+1) == '#' && (sscanf(text, "&#%u;", &pound) == 1) &&
-			pound != 0 && *(text+3+(gint)log10(pound)) == ';') {
+	else if(*(text+1) == '#' &&
+			(sscanf(text, "&#%u%1[;]", &pound, temp) == 2 || sscanf(text, "&#x%x%1[;]", &pound, temp) == 2) &&
+			pound != 0) {
 		static char buf[7];
 		int buflen = g_unichar_to_utf8((gunichar)pound, buf);
 		buf[buflen] = '\0';