Mercurial > pidgin
comparison libpurple/util.c @ 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 | b2aa68cdc8b9 |
children | ae58ffd5e929 |
comparison
equal
deleted
inserted
replaced
21793:f215729af7a7 | 21794:8f82dc5e0b76 |
---|---|
919 const char * | 919 const char * |
920 purple_markup_unescape_entity(const char *text, int *length) | 920 purple_markup_unescape_entity(const char *text, int *length) |
921 { | 921 { |
922 const char *pln; | 922 const char *pln; |
923 int len, pound; | 923 int len, pound; |
924 char temp[2]; | |
924 | 925 |
925 if (!text || *text != '&') | 926 if (!text || *text != '&') |
926 return NULL; | 927 return NULL; |
927 | 928 |
928 #define IS_ENTITY(s) (!g_ascii_strncasecmp(text, s, (len = sizeof(s) - 1))) | 929 #define IS_ENTITY(s) (!g_ascii_strncasecmp(text, s, (len = sizeof(s) - 1))) |
941 pln = "\""; | 942 pln = "\""; |
942 else if(IS_ENTITY("®")) | 943 else if(IS_ENTITY("®")) |
943 pln = "\302\256"; /* or use g_unichar_to_utf8(0xae); */ | 944 pln = "\302\256"; /* or use g_unichar_to_utf8(0xae); */ |
944 else if(IS_ENTITY("'")) | 945 else if(IS_ENTITY("'")) |
945 pln = "\'"; | 946 pln = "\'"; |
946 else if(*(text+1) == '#' && (sscanf(text, "&#%u;", £) == 1) && | 947 else if(*(text+1) == '#' && |
947 pound != 0 && *(text+3+(gint)log10(pound)) == ';') { | 948 (sscanf(text, "&#%u%1[;]", £, temp) == 2 || sscanf(text, "&#x%x%1[;]", £, temp) == 2) && |
949 pound != 0) { | |
948 static char buf[7]; | 950 static char buf[7]; |
949 int buflen = g_unichar_to_utf8((gunichar)pound, buf); | 951 int buflen = g_unichar_to_utf8((gunichar)pound, buf); |
950 buf[buflen] = '\0'; | 952 buf[buflen] = '\0'; |
951 pln = buf; | 953 pln = buf; |
952 | 954 |