function XssUnitTest::testInvalidMultiByte

Checks that invalid multi-byte sequences are rejected.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Common/XssUnitTest.php, line 40
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 testInvalidMultiByte() {

  // Ignore PHP 5.3+ invalid multibyte sequence warning.
  $text = @check_plain("");
  $this
    ->assertEqual($text, '', 'check_plain() rejects invalid sequence "Foo\\xC0barbaz"');

  // Ignore PHP 5.3+ invalid multibyte sequence warning.
  $text = @check_plain("");
  $this
    ->assertEqual($text, '', 'check_plain() rejects invalid sequence "\\xc2\\""');
  $text = check_plain("Fooÿñ");
  $this
    ->assertEqual($text, "Fooÿñ", 'check_plain() accepts valid sequence "Fooÿñ"');
  $text = filter_xss("");
  $this
    ->assertEqual($text, '', 'filter_xss() rejects invalid sequence "Foo\\xC0barbaz"');
  $text = filter_xss("Fooÿñ");
  $this
    ->assertEqual($text, "Fooÿñ", 'filter_xss() accepts valid sequence Fooÿñ');
}