diff --git a/core/lib/Drupal/Component/Utility/SafeMarkup.php b/core/lib/Drupal/Component/Utility/SafeMarkup.php index af9170d..2d8ed9d 100644 --- a/core/lib/Drupal/Component/Utility/SafeMarkup.php +++ b/core/lib/Drupal/Component/Utility/SafeMarkup.php @@ -272,7 +272,7 @@ public static function checkPlain($text) { * * @see t() */ - public static function format($string, array $args = array()) { + public static function format($string, array $args) { $safe = TRUE; // Transform arguments before inserting them. diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php index 054d101..5dc1d2c 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php +++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Entity\Plugin\DataType; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\TypedData\EntityDataDefinition; @@ -114,7 +113,7 @@ public function set($property_name, $value, $notify = TRUE) { */ public function getProperties($include_computed = FALSE) { if (!isset($this->entity)) { - throw new MissingDataException(SafeMarkup::format('Unable to get properties as no entity has been provided.')); + throw new MissingDataException('Unable to get properties as no entity has been provided.'); } if (!$this->entity instanceof FieldableEntityInterface) { // @todo: Add support for config entities in diff --git a/core/modules/filter/src/Plugin/Filter/FilterHtml.php b/core/modules/filter/src/Plugin/Filter/FilterHtml.php index dd39623..f06963a 100644 --- a/core/modules/filter/src/Plugin/Filter/FilterHtml.php +++ b/core/modules/filter/src/Plugin/Filter/FilterHtml.php @@ -7,7 +7,6 @@ namespace Drupal\filter\Plugin\Filter; -use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Form\FormStateInterface; use Drupal\filter\FilterProcessResult; use Drupal\filter\Plugin\FilterBase; @@ -102,7 +101,7 @@ public function tips($long = FALSE) { $output .= '
' . $this->t('This site allows HTML content. While learning all of HTML may feel intimidating, learning how to use a very small number of the most basic HTML "tags" is very easy. This table provides examples for each tag that is enabled on this site.') . '
'; $output .= '' . $this->t('For more information see W3C\'s HTML Specifications or use your favorite search engine to find other sites that explain HTML.', array('@html-specifications' => 'http://www.w3.org/TR/html/')) . '
'; $tips = array( - 'a' => array($this->t('Anchors are used to make links to other pages.'), '' . SafeMarkup::checkPlain(\Drupal::config('system.site')->get('name')) . ''), + 'a' => array($this->t('Anchors are used to make links to other pages.'), '' . htmlspecialchars(\Drupal::config('system.site')->get('name'), ENT_QUOTES, 'UTF-8') . ''), 'br' => array($this->t('By default line break tags are automatically added, so use this tag to add additional ones. Use of this tag is different because it is not used with an open/close pair like all the others. Use the extra " /" inside the tag to maintain XHTML 1.0 compatibility'), $this->t('Text with' . $this->t('Paragraph one.') . '
' . $this->t('Paragraph two.') . '
'), 'strong' => array($this->t('Strong', array(), array('context' => 'Font weight')), '' . $this->t('Strong', array(), array('context' => 'Font weight')) . ''), @@ -144,8 +143,10 @@ public function tips($long = FALSE) { if (!empty($tips[$tag])) { $rows[] = array( array('data' => $tips[$tag][0], 'class' => array('description')), - array('data' => SafeMarkup::format('@var', array('@var' => $tips[$tag][1])), 'class' => array('type')),
- array('data' => SafeMarkup::format($tips[$tag][1]), 'class' => array('get'))
+ // The markup must be escaped.
+ array('data' => ['#prefix' => '', '#markup' => htmlspecialchars($tips[$tag][1], ENT_QUOTES, 'UTF-8'), '#suffix' => ''], 'class' => array('type')),
+ // The markup must not be escaped.
+ array('data' => ['#markup' => $tips[$tag][1]], 'class' => array('get'))
);
}
else {
@@ -175,8 +176,10 @@ public function tips($long = FALSE) {
foreach ($entities as $entity) {
$rows[] = array(
array('data' => $entity[0], 'class' => array('description')),
- array('data' => SafeMarkup::format('@var', array('@var' => $entity[1])), 'class' => array('type')),
- array('data' => SafeMarkup::format($entity[1]), 'class' => array('get'))
+ // The markup must be escaped.
+ array('data' => ['#prefix' => '', '#markup' => htmlspecialchars($entity[1], ENT_QUOTES, 'UTF-8'), '#suffix' => ''], 'class' => array('type')),
+ // The markup must not be escaped.
+ array('data' => ['#markup' => $entity[1]], 'class' => array('get'))
);
}
$table = array(
diff --git a/core/modules/filter/src/Tests/FilterAdminTest.php b/core/modules/filter/src/Tests/FilterAdminTest.php
index 7e6a2d3..d512f8f 100644
--- a/core/modules/filter/src/Tests/FilterAdminTest.php
+++ b/core/modules/filter/src/Tests/FilterAdminTest.php
@@ -368,12 +368,15 @@ function testFilterTipHtmlEscape() {
$this->drupalLogin($this->adminUser);
global $base_url;
+ $site_name_with_markup = 'Filter test site name';
+ $this->config('system.site')->set('name', $site_name_with_markup)->save();
+
// It is not possible to test the whole filter tip page.
// Therefore we test only some parts.
- $link = '' . SafeMarkup::checkPlain(\Drupal::config('system.site')->get('name')) . '';
+ $link = '' . htmlspecialchars($site_name_with_markup, ENT_QUOTES, 'UTF-8') . '';
$ampersand = '&';
- $link_as_code = '' . $link . '';
- $ampersand_as_code = '' . $ampersand . '';
+ $link_as_code = '' . htmlspecialchars($link, ENT_QUOTES, 'UTF-8') . '';
+ $ampersand_as_code = '' . htmlspecialchars($ampersand, ENT_QUOTES, 'UTF-8') . '';
$this->drupalGet('filter/tips');
diff --git a/core/modules/system/tests/modules/menu_test/src/TestControllers.php b/core/modules/system/tests/modules/menu_test/src/TestControllers.php
index f3ff8d2..2a91286 100644
--- a/core/modules/system/tests/modules/menu_test/src/TestControllers.php
+++ b/core/modules/system/tests/modules/menu_test/src/TestControllers.php
@@ -57,7 +57,7 @@ public function testDefaults($placeholder = NULL) {
return ['#markup' => SafeMarkup::format("Sometimes there is a placeholder: '@placeholder'.", array('@placeholder' => $placeholder))];
}
else {
- return ['#markup' => SafeMarkup::format('Sometimes there is no placeholder.')];
+ return ['#markup' => 'Sometimes there is no placeholder.'];
}
}