Loading core/includes/bootstrap.inc +2 −1 Changes for core/includes/bootstrap.inc: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use Drupal\Component\Utility\Unicode; use Drupal\Core\Logger\RfcLogLevel; use Drupal\Core\Render\Markup; use Drupal\Component\Render\MarkupInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Site\Settings; use Drupal\Core\Utility\Error; Loading Loading @@ -441,7 +442,7 @@ function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE) } // Convert strings which are safe to the simplest Markup objects. if (!($message instanceof Markup) && SafeMarkup::isSafe($message)) { if (!($message instanceof Markup) && $message instanceof MarkupInterface) { $message = Markup::create((string) $message); } Loading core/includes/theme.inc +1 −2 Changes for core/includes/theme.inc: 1 added line, 2 removed lines. Original line number Diff line number Diff line Loading @@ -11,7 +11,6 @@ use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Html; use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Render\MarkupInterface; use Drupal\Component\Utility\Unicode; use Drupal\Core\Config\Config; Loading Loading @@ -428,7 +427,7 @@ function theme_render_and_autoescape($arg) { // We have a string or an object converted to a string: Escape it! if (isset($return)) { return SafeMarkup::isSafe($return, 'html') ? $return : Html::escape($return); return $return instanceof MarkupInterface ? $return : Html::escape($return); } // This is a normal render array, which is safe by definition, with special Loading core/lib/Drupal/Component/Render/FormattableMarkup.php +12 −14 Changes for core/lib/Drupal/Component/Render/FormattableMarkup.php: 12 added lines, 14 removed lines. Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ namespace Drupal\Component\Render; use Drupal\Component\Utility\Html; use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\UrlHelper; Loading Loading @@ -199,22 +198,21 @@ protected static function placeholderFormat($string, array $args) { // Escape if the value is not an object from a class that implements // \Drupal\Component\Render\MarkupInterface, for example strings will // be escaped. // \Drupal\Component\Utility\SafeMarkup\SafeMarkup::isSafe() may // return TRUE for content that is safe within HTML fragments, but not // within other contexts, so this placeholder type must not be used // within HTML attributes, JavaScript, or CSS. // Strings that are safe within HTML fragments, but not within other // contexts, may still be an instance of // \Drupal\Component\Render\MarkupInterface, so this placeholder type // must not be used within HTML attributes, JavaScript, or CSS. $args[$key] = static::placeholderEscape($value); break; case ':': // Strip URL protocols that can be XSS vectors. $value = UrlHelper::stripDangerousProtocols($value); // Escape unconditionally, without checking // \Drupal\Component\Utility\SafeMarkup\SafeMarkup::isSafe(). This // forces characters that are unsafe for use in an "href" HTML // attribute to be encoded. If a caller wants to pass a value that is // extracted from HTML and therefore is already HTML encoded, it must // invoke // Escape unconditionally, without checking whether the value is an // instance of \Drupal\Component\Render\MarkupInterface. This forces // characters that are unsafe for use in an "href" HTML attribute to // be encoded. If a caller wants to pass a value that is extracted // from HTML and therefore is already HTML encoded, it must invoke // \Drupal\Component\Render\OutputStrategyInterface::renderFromHtml() // on it prior to passing it in as a placeholder value of this type. // @todo Add some advice and stronger warnings. Loading @@ -226,8 +224,8 @@ protected static function placeholderFormat($string, array $args) { // Similarly to @, escape non-safe values. Also, add wrapping markup // in order to render as a placeholder. Not for use within attributes, // per the warning above about // \Drupal\Component\Utility\SafeMarkup\SafeMarkup::isSafe() and also // due to the wrapping markup. // \Drupal\Component\Render\MarkupInterface and also due to the // wrapping markup. $args[$key] = '<em class="placeholder">' . static::placeholderEscape($value) . '</em>'; break; Loading Loading @@ -256,7 +254,7 @@ protected static function placeholderFormat($string, array $args) { * The properly escaped replacement value. */ protected static function placeholderEscape($value) { return SafeMarkup::isSafe($value) ? (string) $value : Html::escape($value); return $value instanceof MarkupInterface ? (string) $value : Html::escape($value); } } core/lib/Drupal/Component/Render/MarkupInterface.php +0 −1 Changes for core/lib/Drupal/Component/Render/MarkupInterface.php: 0 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ * implement \Countable so it can be used in if statements. * * @see \Drupal\Component\Render\MarkupTrait * @see \Drupal\Component\Utility\SafeMarkup::isSafe() * @see \Drupal\Core\Template\TwigExtension::escapeFilter() * @see \Drupal\Component\Render\FormattableMarkup * @see \Drupal\Core\StringTranslation\TranslatableMarkup Loading core/lib/Drupal/Core/Render/Element/HtmlTag.php +4 −4 Changes for core/lib/Drupal/Core/Render/Element/HtmlTag.php: 4 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -7,8 +7,8 @@ namespace Drupal\Core\Render\Element; use Drupal\Component\Render\MarkupInterface; use Drupal\Component\Utility\Html as HtmlUtility; use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Render\Markup; use Drupal\Component\Utility\Xss; use Drupal\Core\Template\Attribute; Loading Loading @@ -97,7 +97,7 @@ public static function preRenderHtmlTag($element) { // Construct all other elements. else { $markup .= '>'; $markup .= SafeMarkup::isSafe($element['#value']) ? $element['#value'] : Xss::filterAdmin($element['#value']); $markup .= $element['#value'] instanceof MarkupInterface ? $element['#value'] : Xss::filterAdmin($element['#value']); $markup .= '</' . $escaped_tag . ">\n"; } if (!empty($element['#noscript'])) { Loading Loading @@ -171,11 +171,11 @@ public static function preRenderConditionalComments($element) { // Ensure what we are dealing with is safe. // This would be done later anyway in drupal_render(). $prefix = isset($element['#prefix']) ? $element['#prefix'] : ''; if ($prefix && !SafeMarkup::isSafe($prefix)) { if ($prefix && !($prefix instanceof MarkupInterface)) { $prefix = Xss::filterAdmin($prefix); } $suffix = isset($element['#suffix']) ? $element['#suffix'] : ''; if ($suffix && !SafeMarkup::isSafe($suffix)) { if ($suffix && !($suffix instanceof MarkupInterface)) { $suffix = Xss::filterAdmin($suffix); } Loading Loading
core/includes/bootstrap.inc +2 −1 Changes for core/includes/bootstrap.inc: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use Drupal\Component\Utility\Unicode; use Drupal\Core\Logger\RfcLogLevel; use Drupal\Core\Render\Markup; use Drupal\Component\Render\MarkupInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Site\Settings; use Drupal\Core\Utility\Error; Loading Loading @@ -441,7 +442,7 @@ function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE) } // Convert strings which are safe to the simplest Markup objects. if (!($message instanceof Markup) && SafeMarkup::isSafe($message)) { if (!($message instanceof Markup) && $message instanceof MarkupInterface) { $message = Markup::create((string) $message); } Loading
core/includes/theme.inc +1 −2 Changes for core/includes/theme.inc: 1 added line, 2 removed lines. Original line number Diff line number Diff line Loading @@ -11,7 +11,6 @@ use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Html; use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Render\MarkupInterface; use Drupal\Component\Utility\Unicode; use Drupal\Core\Config\Config; Loading Loading @@ -428,7 +427,7 @@ function theme_render_and_autoescape($arg) { // We have a string or an object converted to a string: Escape it! if (isset($return)) { return SafeMarkup::isSafe($return, 'html') ? $return : Html::escape($return); return $return instanceof MarkupInterface ? $return : Html::escape($return); } // This is a normal render array, which is safe by definition, with special Loading
core/lib/Drupal/Component/Render/FormattableMarkup.php +12 −14 Changes for core/lib/Drupal/Component/Render/FormattableMarkup.php: 12 added lines, 14 removed lines. Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ namespace Drupal\Component\Render; use Drupal\Component\Utility\Html; use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\UrlHelper; Loading Loading @@ -199,22 +198,21 @@ protected static function placeholderFormat($string, array $args) { // Escape if the value is not an object from a class that implements // \Drupal\Component\Render\MarkupInterface, for example strings will // be escaped. // \Drupal\Component\Utility\SafeMarkup\SafeMarkup::isSafe() may // return TRUE for content that is safe within HTML fragments, but not // within other contexts, so this placeholder type must not be used // within HTML attributes, JavaScript, or CSS. // Strings that are safe within HTML fragments, but not within other // contexts, may still be an instance of // \Drupal\Component\Render\MarkupInterface, so this placeholder type // must not be used within HTML attributes, JavaScript, or CSS. $args[$key] = static::placeholderEscape($value); break; case ':': // Strip URL protocols that can be XSS vectors. $value = UrlHelper::stripDangerousProtocols($value); // Escape unconditionally, without checking // \Drupal\Component\Utility\SafeMarkup\SafeMarkup::isSafe(). This // forces characters that are unsafe for use in an "href" HTML // attribute to be encoded. If a caller wants to pass a value that is // extracted from HTML and therefore is already HTML encoded, it must // invoke // Escape unconditionally, without checking whether the value is an // instance of \Drupal\Component\Render\MarkupInterface. This forces // characters that are unsafe for use in an "href" HTML attribute to // be encoded. If a caller wants to pass a value that is extracted // from HTML and therefore is already HTML encoded, it must invoke // \Drupal\Component\Render\OutputStrategyInterface::renderFromHtml() // on it prior to passing it in as a placeholder value of this type. // @todo Add some advice and stronger warnings. Loading @@ -226,8 +224,8 @@ protected static function placeholderFormat($string, array $args) { // Similarly to @, escape non-safe values. Also, add wrapping markup // in order to render as a placeholder. Not for use within attributes, // per the warning above about // \Drupal\Component\Utility\SafeMarkup\SafeMarkup::isSafe() and also // due to the wrapping markup. // \Drupal\Component\Render\MarkupInterface and also due to the // wrapping markup. $args[$key] = '<em class="placeholder">' . static::placeholderEscape($value) . '</em>'; break; Loading Loading @@ -256,7 +254,7 @@ protected static function placeholderFormat($string, array $args) { * The properly escaped replacement value. */ protected static function placeholderEscape($value) { return SafeMarkup::isSafe($value) ? (string) $value : Html::escape($value); return $value instanceof MarkupInterface ? (string) $value : Html::escape($value); } }
core/lib/Drupal/Component/Render/MarkupInterface.php +0 −1 Changes for core/lib/Drupal/Component/Render/MarkupInterface.php: 0 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ * implement \Countable so it can be used in if statements. * * @see \Drupal\Component\Render\MarkupTrait * @see \Drupal\Component\Utility\SafeMarkup::isSafe() * @see \Drupal\Core\Template\TwigExtension::escapeFilter() * @see \Drupal\Component\Render\FormattableMarkup * @see \Drupal\Core\StringTranslation\TranslatableMarkup Loading
core/lib/Drupal/Core/Render/Element/HtmlTag.php +4 −4 Changes for core/lib/Drupal/Core/Render/Element/HtmlTag.php: 4 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -7,8 +7,8 @@ namespace Drupal\Core\Render\Element; use Drupal\Component\Render\MarkupInterface; use Drupal\Component\Utility\Html as HtmlUtility; use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Render\Markup; use Drupal\Component\Utility\Xss; use Drupal\Core\Template\Attribute; Loading Loading @@ -97,7 +97,7 @@ public static function preRenderHtmlTag($element) { // Construct all other elements. else { $markup .= '>'; $markup .= SafeMarkup::isSafe($element['#value']) ? $element['#value'] : Xss::filterAdmin($element['#value']); $markup .= $element['#value'] instanceof MarkupInterface ? $element['#value'] : Xss::filterAdmin($element['#value']); $markup .= '</' . $escaped_tag . ">\n"; } if (!empty($element['#noscript'])) { Loading Loading @@ -171,11 +171,11 @@ public static function preRenderConditionalComments($element) { // Ensure what we are dealing with is safe. // This would be done later anyway in drupal_render(). $prefix = isset($element['#prefix']) ? $element['#prefix'] : ''; if ($prefix && !SafeMarkup::isSafe($prefix)) { if ($prefix && !($prefix instanceof MarkupInterface)) { $prefix = Xss::filterAdmin($prefix); } $suffix = isset($element['#suffix']) ? $element['#suffix'] : ''; if ($suffix && !SafeMarkup::isSafe($suffix)) { if ($suffix && !($suffix instanceof MarkupInterface)) { $suffix = Xss::filterAdmin($suffix); } Loading