fixes #4976, escape chars in attributes of xml tags

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7253 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2008-06-24 01:38:40 +00:00
parent 013e9889e5
commit 38bbfb66ce
2 changed files with 14 additions and 1 deletions

View file

@ -592,7 +592,7 @@ class XmlNode extends Object {
if (is_array($this->attributes) && count($this->attributes) > 0) {
foreach ($this->attributes as $key => $val) {
$val = str_replace('"', '\"', $val);
$d .= ' ' . $key . '="' . $val . '"';
$d .= ' ' . $key . '="' . h($val) . '"';
}
}
}

View file

@ -542,5 +542,18 @@ class XmlTest extends UnitTestCase {
$result = $xml->toString(array('cdata' => false));
$this->assertEqual($expects, $result);
}
/**
* testEscapeCharSerialization method
*
* @access public
* @return void
*/
function testEscapeCharSerialization() {
$xml = new Xml(array('text' => 'JavaScript & DHTML'), array('attributes' => false, 'format' => 'attributes'));
$result = $xml->toString(false);
$expected = '<std_class text="JavaScript &amp; DHTML" />';
$this->assertEqual($expected, $result);
}
}
?>