Commit be164e45 by DaSourcerer

Handle invalid code sequences in Html::encode()

parent 2b26dd32
...@@ -92,7 +92,7 @@ class BaseHtml ...@@ -92,7 +92,7 @@ class BaseHtml
*/ */
public static function encode($content, $doubleEncode = true) public static function encode($content, $doubleEncode = true)
{ {
return htmlspecialchars($content, ENT_QUOTES, Yii::$app->charset, $doubleEncode); return htmlspecialchars($content, ENT_QUOTES | ENT_SUBSTITUTE, Yii::$app->charset, $doubleEncode);
} }
/** /**
......
...@@ -38,7 +38,7 @@ class HtmlTest extends TestCase ...@@ -38,7 +38,7 @@ class HtmlTest extends TestCase
public function testEncode() public function testEncode()
{ {
$this->assertEquals("a&lt;&gt;&amp;&quot;&#039;", Html::encode("a<>&\"'")); $this->assertEquals("a&lt;&gt;&amp;&quot;&#039;�", Html::encode("a<>&\"'\x80"));
} }
public function testDecode() public function testDecode()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment