Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html_attr: do not escape colons #3614

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Extension/EscaperExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ function twig_escape_filter(Environment $env, $string, $strategy = 'html', $char
throw new RuntimeError('The string to escape is not a valid UTF-8 string.');
}

$string = preg_replace_callback('#[^a-zA-Z0-9,\.\-_]#Su', function ($matches) {
$string = preg_replace_callback('#[^a-zA-Z0-9,\.\-_:]#Su', function ($matches) {
/**
* This function is adapted from code coming from Zend Framework.
*
Expand Down
3 changes: 2 additions & 1 deletion tests/Extension/EscaperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Twig_Tests_Extension_EscaperTest extends TestCase
'.' => '.',
'-' => '-',
'_' => '_',
':' => ':',
/* Basic alnums excluded */
'a' => 'a',
'A' => 'A',
Expand Down Expand Up @@ -314,7 +315,7 @@ public function testJavascriptEscapingEscapesOwaspRecommendedRanges()
public function testHtmlAttributeEscapingEscapesOwaspRecommendedRanges()
{
$twig = new Environment($this->createMock(LoaderInterface::class));
$immune = [',', '.', '-', '_']; // Exceptions to escaping ranges
$immune = [',', '.', '-', '_', ':']; // Exceptions to escaping ranges
for ($chr = 0; $chr < 0xFF; ++$chr) {
if ($chr >= 0x30 && $chr <= 0x39
|| $chr >= 0x41 && $chr <= 0x5A
Expand Down