Skip to content

Commit

Permalink
xmlparse: stop escaping special characters in CDATA, fixes #10765
Browse files Browse the repository at this point in the history
The CDATA section is especially designed so that special characters do not
need to be escaped.
Escaping them twice results in invalid XML being produced which breaks
other parsers.
  • Loading branch information
sbraz committed Sep 2, 2020
1 parent a903e9a commit 95d37e7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/etc/inc/xmlparse.inc
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ function cData($parser, $data) {
}

if (is_string($ptr)) {
$ptr .= html_entity_decode($data);
$ptr .= $data;
} else {
if (trim($data, " ") != "") {
$ptr = html_entity_decode($data);
$ptr = $data;
$havedata++;
}
}
Expand Down Expand Up @@ -264,7 +264,7 @@ function dump_xml_config_sub($arr, $indent) {
if ((is_bool($cval) && $cval == true) || ($cval === "")) {
$xmlconfig .= "<$ent></$ent>\n";
} else if (is_cdata_entity($ent)) {
$xmlconfig .= "<$ent><![CDATA[" . htmlentities($cval) . "]]></$ent>\n";
$xmlconfig .= "<$ent><![CDATA[" . $cval . "]]></$ent>\n";
} else {
$xmlconfig .= "<$ent>" . htmlentities($cval) . "</$ent>\n";
}
Expand All @@ -288,7 +288,7 @@ function dump_xml_config_sub($arr, $indent) {
} else if (!is_bool($val)) {
$xmlconfig .= str_repeat("\t", $indent);
if (is_cdata_entity($ent)) {
$xmlconfig .= "<$ent><![CDATA[" . htmlentities($val) . "]]></$ent>\n";
$xmlconfig .= "<$ent><![CDATA[" . $val . "]]></$ent>\n";
} else {
$xmlconfig .= "<$ent>" . htmlentities($val) . "</$ent>\n";
}
Expand Down

0 comments on commit 95d37e7

Please sign in to comment.