diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 38d20a982d03de285ae52408dc8d37b31687506f..62329f851ed2ab3ee8c764f5a919deed37c9a927 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -1905,7 +1905,7 @@ function format_string($string, array $args = array()) { * @ingroup sanitization */ function check_plain($text) { - return htmlspecialchars($text, ENT_QUOTES, 'UTF-8'); + return htmlspecialchars((string) $text, ENT_QUOTES, 'UTF-8'); } /** diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index b22c4a6f5ccab9d3a3b8f53ce57175c07f562298..3b4d731da3ca86da7a50aac5daf017283e4cd080 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -480,6 +480,11 @@ class CommonXssUnitTest extends DrupalUnitTestCase { * Check that invalid multi-byte sequences are rejected. */ function testInvalidMultiByte() { + // Ignore PHP 8.0+ null deprecatations. + $text = check_plain(NULL); + $this->assertEqual($text, '', 'check_plain() casts null to string'); + $text = check_plain(FALSE); + $this->assertEqual($text, '', 'check_plain() casts boolean to string'); // Ignore PHP 5.3+ invalid multibyte sequence warning. $text = @check_plain("Foo\xC0barbaz"); $this->assertEqual($text, '', 'check_plain() rejects invalid sequence "Foo\xC0barbaz"');