function XssTest::assertNotNormalized

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Component/Utility/XssTest.php \Drupal\Tests\Component\Utility\XssTest::assertNotNormalized()
  2. 10 core/tests/Drupal/Tests/Component/Utility/XssTest.php \Drupal\Tests\Component\Utility\XssTest::assertNotNormalized()
  3. 11.x core/tests/Drupal/Tests/Component/Utility/XssTest.php \Drupal\Tests\Component\Utility\XssTest::assertNotNormalized()

Asserts that text transformed to lowercase with HTML entities decoded does not contain a given string.

Otherwise fails the test with a given message, similar to all the SimpleTest assert* functions.

Note that this does not remove nulls, new lines, and other character that could be used to obscure a tag or an attribute name.

@internal

Parameters

string $haystack: Text to look in.

string $needle: Lowercase, plain text to look for.

string $message: (optional) Message to display if failed. Defaults to an empty string.

2 calls to XssTest::assertNotNormalized()
XssTest::testFilterXssAdminNotNormalized in core/tests/Drupal/Tests/Component/Utility/XssTest.php
Tests the loose, admin HTML filter.
XssTest::testFilterXssNotNormalized in core/tests/Drupal/Tests/Component/Utility/XssTest.php
Tests limiting to allowed tags and XSS prevention.

File

core/tests/Drupal/Tests/Component/Utility/XssTest.php, line 660

Class

XssTest
XSS Filtering tests.

Namespace

Drupal\Tests\Component\Utility

Code

protected function assertNotNormalized(string $haystack, string $needle, string $message = '') : void {
    $this->assertStringNotContainsString($needle, strtolower(Html::decodeEntities($haystack)), $message);
}

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