Merge commit from fork

This commit is contained in:
Dmitry Verenitsin
2026-08-08 17:07:32 +03:00
committed by GitHub
parent 68ec688eb6
commit 587474a158
2 changed files with 34 additions and 1 deletions
+3 -1
View File
@@ -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) {
+31
View File
@@ -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&empty;, &name;&empty;!</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()
}