diff --git a/core/modules/ckeditor/ckeditor.admin.inc b/core/modules/ckeditor/ckeditor.admin.inc
index 4ee12bb..21be21d 100644
--- a/core/modules/ckeditor/ckeditor.admin.inc
+++ b/core/modules/ckeditor/ckeditor.admin.inc
@@ -7,7 +7,6 @@
use Drupal\Component\Utility\Html;
use Drupal\Core\Template\Attribute;
-use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Language\LanguageInterface;
/**
@@ -66,10 +65,10 @@ function template_preprocess_ckeditor_settings_toolbar(&$variables) {
$build_button_item = function($button, $rtl) {
// Value of the button item.
if (isset($button['image_alternative' . $rtl])) {
- $value = SafeMarkup::set($button['image_alternative' . $rtl]);
+ $value = $button['image_alternative' . $rtl];
}
elseif (isset($button['image_alternative'])) {
- $value = SafeMarkup::set($button['image_alternative']);
+ $value = $button['image_alternative'];
}
elseif (isset($button['image'])) {
$value = array(
diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php
index c405c7f..1d3690e 100644
--- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php
+++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php
@@ -9,6 +9,7 @@
use Drupal\ckeditor\CKEditorPluginBase;
use Drupal\Component\Utility\NestedArray;
+use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
@@ -127,7 +128,10 @@ public function getConfig(Editor $editor) {
*/
public function getButtons() {
$button = function($name, $direction = 'ltr') {
- return '' . $name . '';
+ // In the markup below, we mostly use the name (which may include spaces),
+ // but in one spot we use it as a CSS class, so strip spaces.
+ $class_name = str_replace(' ', '', $name);
+ return SafeMarkup::format('@name', ['@direction' => $direction, '@name' => $name, '@classname' => $class_name]);
};
return array(
@@ -256,7 +260,7 @@ public function getButtons() {
),
'Format' => array(
'label' => t('HTML block format'),
- 'image_alternative' => '' . t('Format') . '',
+ 'image_alternative' => SafeMarkup::format('@format_text', ['@format_text' => t('Format')]),
),
// "table" plugin.
'Table' => array(
@@ -282,7 +286,7 @@ public function getButtons() {
// No plugin, separator "button" for toolbar builder UI use only.
'-' => array(
'label' => t('Separator'),
- 'image_alternative' => '',
+ 'image_alternative' => SafeMarkup::format('', ['@button_separator_text' => t('Button separator')]),
'attributes' => array(
'class' => array('ckeditor-button-separator'),
'data-drupal-ckeditor-type' => 'separator',
diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php
index d569930..a260702 100644
--- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php
+++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php
@@ -10,6 +10,7 @@
use Drupal\ckeditor\CKEditorPluginBase;
use Drupal\ckeditor\CKEditorPluginConfigurableInterface;
use Drupal\Component\Utility\NestedArray;
+use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Form\FormStateInterface;
use Drupal\editor\Entity\Editor;
@@ -59,7 +60,7 @@ public function getButtons() {
return array(
'Styles' => array(
'label' => t('Font style'),
- 'image_alternative' => '' . t('Styles') . '',
+ 'image_alternative' => SafeMarkup::format('@styles_text', ['@styles_text' => t('Styles')]),
),
);
}
diff --git a/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php b/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php
index 6849757..74c62b9 100644
--- a/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php
+++ b/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php
@@ -164,6 +164,19 @@ function testExistingFormat() {
$this->assertTrue($editor instanceof Editor, 'An Editor config entity exists.');
$this->assertIdentical($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.');
+ // Check that the markup we're setting for the toolbar buttons (actually in
+ // JavaScript's drupalSettings, and Unicode-escaped) is correctly rendered.
+ $this->drupalGet('admin/config/content/formats/manage/filtered_html');
+ $this->verbose($this->content);
+ // Check the Button separator.
+ $this->assertRaw('\u003Cli data-drupal-ckeditor-button-name=\u0022-\u0022 class=\u0022ckeditor-button-separator ckeditor-multiple-button\u0022 data-drupal-ckeditor-type=\u0022separator\u0022\u003E\u003Ca href=\u0022#\u0022 role=\u0022button\u0022 aria-label=\u0022Button separator\u0022 class=\u0022ckeditor-separator\u0022\u003E\u003C\/a\u003E\u003C\/li\u003E');
+ // Check the Format dropdown.
+ $this->assertRaw('\u003Cli data-drupal-ckeditor-button-name=\u0022Format\u0022 class=\u0022ckeditor-button\u0022\u003E\u003Ca href=\u0022#\u0022 role=\u0022button\u0022 aria-label=\u0022Format\u0022\u003E\u003Cspan class=\u0022ckeditor-button-dropdown\u0022\u003EFormat\u003Cspan class=\u0022ckeditor-button-arrow\u0022\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/a\u003E\u003C\/li\u003E');
+ // Check the Styles dropdown.
+ $this->assertRaw('\u003Cli data-drupal-ckeditor-button-name=\u0022Styles\u0022 class=\u0022ckeditor-button\u0022\u003E\u003Ca href=\u0022#\u0022 role=\u0022button\u0022 aria-label=\u0022Styles\u0022\u003E\u003Cspan class=\u0022ckeditor-button-dropdown\u0022\u003EStyles\u003Cspan class=\u0022ckeditor-button-arrow\u0022\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/a\u003E\u003C\/li\u003E');
+ // Check strikethrough.
+ $this->assertRaw('\u003Cli data-drupal-ckeditor-button-name=\u0022Strike\u0022 class=\u0022ckeditor-button\u0022\u003E\u003Ca href=\u0022#\u0022 class=\u0022cke-icon-only cke_ltr\u0022 role=\u0022button\u0022 title=\u0022strike\u0022 aria-label=\u0022strike\u0022\u003E\u003Cspan class=\u0022cke_button_icon cke_button__strike_icon\u0022\u003Estrike\u003C\/span\u003E\u003C\/a\u003E\u003C\/li\u003E');
+
// Now enable the ckeditor_test module, which provides one configurable
// CKEditor plugin — this should not affect the Editor config entity.
\Drupal::service('module_installer')->install(array('ckeditor_test'));