function XssUnitTest::testEscaping

Checks that special characters are escaped.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Common/XssUnitTest.php, line 58
Definition of Drupal\system\Tests\Common\XssUnitTest.

Class

XssUnitTest
Tests for check_plain(), filter_xss(), format_string(), and check_url().

Namespace

Drupal\system\Tests\Common

Code

function testEscaping() {
  $text = check_plain("<script>");
  $this
    ->assertEqual($text, '&lt;script&gt;', 'check_plain() escapes &lt;script&gt;');
  $text = check_plain('<>&"\'');
  $this
    ->assertEqual($text, '&lt;&gt;&amp;&quot;&#039;', 'check_plain() escapes reserved HTML characters.');
}