You are here

public function Twig_Test_EscapingTest::testCssEscapingEscapesOwaspRecommendedRanges in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/twig/twig/test/Twig/Tests/escapingTest.php \Twig_Test_EscapingTest::testCssEscapingEscapesOwaspRecommendedRanges()

File

vendor/twig/twig/test/Twig/Tests/escapingTest.php, line 302

Class

Twig_Test_EscapingTest
This class is adapted from code coming from Zend Framework.

Code

public function testCssEscapingEscapesOwaspRecommendedRanges() {

  // CSS has no 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, 'css'));
    }
    else {
      $literal = $this
        ->codepointToUtf8($chr);
      $this
        ->assertNotEquals($literal, twig_escape_filter($this->env, $literal, 'css'), "{$literal} should be escaped!");
    }
  }
}