Created
July 26, 2022 10:54
-
-
Save ivangrozni/bc90d26ba5c7bdb6901577103b816ac0 to your computer and use it in GitHub Desktop.
ldp-1555-drupal-core-3276589-php81-compatibility-html-special-chars.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From a69b1ddfaee8be5160c46b40f7dde4cdcbd8c17b Mon Sep 17 00:00:00 2001 | |
From: Wong Hoi Sing Edison <hswong3i@pantarei-design.com> | |
Date: Sun, 16 Jan 2022 23:51:01 +0800 | |
Subject: [PATCH] Issue #3255637: htmlspecialchars(): Passing null to parameter | |
#1 ($string) of type string is deprecated | |
--- | |
core/lib/Drupal/Component/Render/FormattableMarkup.php | 2 +- | |
.../Tests/Component/Render/FormattableMarkupTest.php | 10 ++++++++++ | |
2 files changed, 11 insertions(+), 1 deletion(-) | |
diff --git a/core/lib/Drupal/Component/Render/FormattableMarkup.php b/core/lib/Drupal/Component/Render/FormattableMarkup.php | |
index d9cb205fe64..f1430c83fdc 100644 | |
--- a/core/lib/Drupal/Component/Render/FormattableMarkup.php | |
+++ b/core/lib/Drupal/Component/Render/FormattableMarkup.php | |
@@ -259,7 +259,7 @@ protected static function placeholderFormat($string, array $args) { | |
* The properly escaped replacement value. | |
*/ | |
protected static function placeholderEscape($value) { | |
- return $value instanceof MarkupInterface ? (string) $value : Html::escape($value); | |
+ return $value instanceof MarkupInterface ? (string) $value : Html::escape($value ?? ''); | |
} | |
} | |
diff --git a/core/tests/Drupal/Tests/Component/Render/FormattableMarkupTest.php b/core/tests/Drupal/Tests/Component/Render/FormattableMarkupTest.php | |
index fc285287e1e..7eb4398a1ad 100644 | |
--- a/core/tests/Drupal/Tests/Component/Render/FormattableMarkupTest.php | |
+++ b/core/tests/Drupal/Tests/Component/Render/FormattableMarkupTest.php | |
@@ -43,6 +43,16 @@ public function testToString() { | |
$this->assertEquals('Can I please have a kitten', $text); | |
} | |
+ /** | |
+ * @covers ::__toString | |
+ */ | |
+ public function testNullReplacementToString() { | |
+ $string = 'Can I please have a @replacement'; | |
+ $formattable_string = new FormattableMarkup($string, ['@replacement' => NULL]); | |
+ $text = (string) $formattable_string; | |
+ $this->assertEquals('Can I please have a ', $text); | |
+ } | |
+ | |
/** | |
* @covers ::count | |
*/ | |
-- | |
GitLab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment