public function testJavascriptEscapingEscapesOwaspRecommendedRanges() {
$immune = array(
',',
'.',
'_',
);
// Exceptions to escaping ranges
for ($chr = 0; $chr < 0xff; $chr++) {
if ($chr >= 0x30 && $chr <= 0x39 || $chr >= 0x41 && $chr <= 0x5a || $chr >= 0x61 && $chr <= 0x7a) {
$literal = $this
->codepointToUtf8($chr);
$this
->assertEquals($literal, twig_escape_filter($this->env, $literal, 'js'));
}
else {
$literal = $this
->codepointToUtf8($chr);
if (in_array($literal, $immune)) {
$this
->assertEquals($literal, twig_escape_filter($this->env, $literal, 'js'));
}
else {
$this
->assertNotEquals($literal, twig_escape_filter($this->env, $literal, 'js'), "{$literal} should be escaped!");
}
}
}
}