Skip to content

Commit

Permalink
Invalid escaping in renderBaseAttrs()
Browse files Browse the repository at this point in the history
Summary:
Second parameter of htmlspecialchars() is flags (int), not bool.
Value true is understood as 1 which means: quote single quotes, not double quotes

Test Plan:
New test
  • Loading branch information
Jakub Vrana committed Feb 15, 2012
1 parent 0ff0c6d commit 0a99f67
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion php-lib/html.php
Expand Up @@ -65,7 +65,7 @@ protected final function renderBaseAttrs() {
$buf = '<'.$this->tagName;
foreach ($this->getAttributes() as $key => $val) {
if ($val !== null && $val !== false) {
$buf .= ' ' . htmlspecialchars($key) . '="' . htmlspecialchars($val, true) . '"';
$buf .= ' ' . htmlspecialchars($key) . '="' . htmlspecialchars($val) . '"';
}
}
return $buf;
Expand Down
9 changes: 9 additions & 0 deletions tests/attr-quotes.phpt
@@ -0,0 +1,9 @@
--TEST--
Quotes in attribute
--FILE--
<?php
class xhp_a {}
$quote = '"';
echo <a b={$quote}>c</a>;
--EXPECT--
<a b="&quot;">c</a>

0 comments on commit 0a99f67

Please sign in to comment.