Skip to content

Commit

Permalink
[Form] avoid double-escape and then unescape
Browse files Browse the repository at this point in the history
htmlspecialchars' fourth parameter allows you to avoid double-escaping in the first place
  • Loading branch information
Seldaek authored and fabpot committed Sep 19, 2010
1 parent e6bff04 commit 71cc3a7
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions src/Symfony/Component/Form/HtmlGenerator.php
Expand Up @@ -120,18 +120,6 @@ private function attributesCallback($name, $value)
*/
public function escape($value)
{
return $this->fixDoubleEscape(htmlspecialchars((string) $value, ENT_QUOTES, $this->charset));
}

/**
* Fixes double escaped strings.
*
* @param string $escaped string to fix
*
* @return string A single escaped string
*/
protected function fixDoubleEscape($escaped)
{
return preg_replace('/&([a-z]+|(#\d+)|(#x[\da-f]+));/i', '&$1;', $escaped);
return htmlspecialchars((string) $value, ENT_QUOTES, $this->charset, false);
}
}

0 comments on commit 71cc3a7

Please sign in to comment.