Commit 55e20f3f authored by Drew Webber's avatar Drew Webber
Browse files

Issue #3270546 by mcdruid, poker10, mfb: PHP 8.1 str_replace(): Passing null...

Issue #3270546 by mcdruid, poker10, mfb: PHP 8.1 str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in filter_xss()
parent a7cc9406
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1933,7 +1933,7 @@ function check_plain($text) {
 *   TRUE if the text is valid UTF-8, FALSE if not.
 */
function drupal_validate_utf8($text) {
  if (strlen($text) == 0) {
  if (strlen((string) $text) == 0) {
    return TRUE;
  }
  // With the PCRE_UTF8 modifier 'u', preg_match() fails silently on strings
+1 −1
Original line number Diff line number Diff line
@@ -1500,7 +1500,7 @@ function filter_xss($string, $allowed_tags = array('a', 'em', 'strong', 'cite',
  // Store the text format.
  _filter_xss_split($allowed_tags, TRUE);
  // Remove NULL characters (ignored by some browsers).
  $string = str_replace(chr(0), '', $string);
  $string = str_replace(chr(0), '', (string) $string);
  // Remove Netscape 4 JS entities.
  $string = preg_replace('%&\s*\{[^}]*(\}\s*;?|$)%', '', $string);

+5 −1
Original line number Diff line number Diff line
@@ -480,11 +480,15 @@ class CommonXssUnitTest extends DrupalUnitTestCase {
   * Check that invalid multi-byte sequences are rejected.
   */
  function testInvalidMultiByte() {
     // Ignore PHP 8.0+ null deprecatations.
     // Ignore PHP 8.0+ null deprecations.
     $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');
     $text = filter_xss(NULL);
     $this->assertEqual($text, '', 'filter_xss() casts null to string');
     $text = filter_xss(FALSE);
     $this->assertEqual($text, '', 'filter_xss() 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"');