Skip to content

Commit f75734b

Browse files
committed
html_attr: do not escape colons
1 parent 115114b commit f75734b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Runtime/EscaperRuntime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public function escape($string, string $strategy = 'html', ?string $charset = nu
259259
throw new RuntimeError('The string to escape is not a valid UTF-8 string.');
260260
}
261261

262-
$string = preg_replace_callback('#[^a-zA-Z0-9,\.\-_]#Su', function ($matches) {
262+
$string = preg_replace_callback('#[^a-zA-Z0-9,\.\-_:]#Su', function ($matches) {
263263
/**
264264
* This function is adapted from code coming from Zend Framework.
265265
*

tests/Runtime/EscaperRuntimeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class EscaperRuntimeTest extends TestCase
3838
'.' => '.',
3939
'-' => '-',
4040
'_' => '_',
41+
':' => ':',
4142
/* Basic alnums excluded */
4243
'a' => 'a',
4344
'A' => 'A',
@@ -300,7 +301,7 @@ public function testJavascriptEscapingEscapesOwaspRecommendedRanges()
300301

301302
public function testHtmlAttributeEscapingEscapesOwaspRecommendedRanges()
302303
{
303-
$immune = [',', '.', '-', '_']; // Exceptions to escaping ranges
304+
$immune = [',', '.', '-', '_', ':']; // Exceptions to escaping ranges
304305
for ($chr = 0; $chr < 0xFF; ++$chr) {
305306
if ($chr >= 0x30 && $chr <= 0x39
306307
|| $chr >= 0x41 && $chr <= 0x5A

0 commit comments

Comments
 (0)