Skip to content

Commit 5b62a82

Browse files
test: add tests for escaped html
1 parent f7b172a commit 5b62a82

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/View.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function setParam(string $key, mixed $value, bool $escapeHtml = true): st
8484
}
8585

8686
if (is_string($value) && $escapeHtml) {
87-
$value = htmlspecialchars($value, encoding: 'UTF-8');
87+
$value = \htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
8888
}
8989

9090
$this->params[$key] = $value;

tests/ViewTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,10 @@ public function testCanFilterNewLinesToParagraphs()
8383
{
8484
$this->assertEquals('<p>line1</p><p>line2</p>', $this->view->print("line1\n\nline2", View::FILTER_NL2P));
8585
}
86+
87+
public function testCanSetParamWithEscapedHtml()
88+
{
89+
$this->view->setParam('key', '<html>value</html>');
90+
$this->assertEquals('&lt;html&gt;value&lt;/html&gt;', $this->view->getParam('key', 'default'));
91+
}
8692
}

0 commit comments

Comments
 (0)