Skip to content

Commit

Permalink
Escape special characters in XML.
Browse files Browse the repository at this point in the history
Fixes #2188.
  • Loading branch information
ingk authored and markstory committed Nov 26, 2011
1 parent 54aef72 commit a516268
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/Cake/Utility/Xml.php
Expand Up @@ -200,7 +200,16 @@ protected static function _fromArray($dom, $node, &$data, $format) {
continue;
}
if ($key[0] !== '@' && $format === 'tags') {
$child = $dom->createElement($key, $value);
$child = null;
if (!is_numeric($value)) {
// Escape special characters
// http://www.w3.org/TR/REC-xml/#syntax
// https://bugs.php.net/bug.php?id=36795
$child = $dom->createElement($key, '');
$child->appendChild(new DOMText($value));
} else {
$child = $dom->createElement($key, $value);
}
$node->appendChild($child);
} else {
if ($key[0] === '@') {
Expand Down

0 comments on commit a516268

Please sign in to comment.