mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-08-19 09:40:21 +00:00
Merge commit from fork
This commit is contained in:
+3
-1
@@ -658,7 +658,9 @@ static char *switch_xml_decode(char *s, char **ent, char t)
|
||||
for (b = 0; ent[b] && strncmp(s + 1, ent[b], strlen(ent[b])); b += 2); /* find entity in entity list */
|
||||
|
||||
if (ent[b++]) { /* found a match */
|
||||
if ((c = (unsigned long) strlen(ent[b])) - 1 > (e = strchr(s, ';')) - s) {
|
||||
c = (unsigned long) strlen(ent[b]);
|
||||
e = strchr(s, ';');
|
||||
if (c && c - 1 > (unsigned long)(e - s)) {
|
||||
l = (d = (unsigned long) (s - r)) + c + (unsigned long) strlen(e); /* new length */
|
||||
if (l) {
|
||||
if (r == m) {
|
||||
|
||||
@@ -250,6 +250,37 @@ FST_MINCORE_BEGIN("./conf")
|
||||
switch_xml_free(xml);
|
||||
}
|
||||
FST_TEST_END()
|
||||
|
||||
FST_TEST_BEGIN(test_empty_entity_decode)
|
||||
{
|
||||
const char *text =
|
||||
"<xml><!DOCTYPE Response ["
|
||||
"<!ENTITY empty \"\">"
|
||||
"<!ENTITY name \"World\">"
|
||||
"]><Response><Say>Hello∅, &name;∅!</Say></Response></xml>";
|
||||
switch_xml_t xml = NULL;
|
||||
char *xml_string = NULL;
|
||||
|
||||
xml = switch_xml_parse_str_dynamic((char *)text, SWITCH_TRUE);
|
||||
if (!xml) {
|
||||
fst_fail("failed to parse XML with empty entity");
|
||||
goto test_empty_entity_decode_done;
|
||||
}
|
||||
|
||||
xml_string = switch_xml_toxml_ex(xml, SWITCH_FALSE, SWITCH_FALSE);
|
||||
if (!xml_string) {
|
||||
fst_fail("failed to serialize parsed XML");
|
||||
goto test_empty_entity_decode_done;
|
||||
}
|
||||
|
||||
fst_check_string_equals(xml_string,
|
||||
"<xml>\n <Response>\n <Say>Hello, World!</Say>\n </Response>\n</xml>\n");
|
||||
|
||||
test_empty_entity_decode_done:
|
||||
free(xml_string);
|
||||
if (xml) switch_xml_free(xml);
|
||||
}
|
||||
FST_TEST_END()
|
||||
}
|
||||
FST_SUITE_END()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user