function CommonXssUnitTest::testEscaping

Check that special characters are escaped.

File

modules/simpletest/tests/common.test, line 529

Class

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

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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.