.../ckeditor/Plugin/CKEditorPlugin/Internal.php | 20 ++++++++++++-------- .../lib/Drupal/ckeditor/Tests/CKEditorTest.php | 6 ++++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/Internal.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/Internal.php index d206597..5e8dec8 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/Internal.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/Internal.php @@ -320,8 +320,12 @@ protected function generateAllowedContentSetting(Editor $editor) { 'classes' => FALSE, ); } - // Tell CKEditor the tag is allowed, as well as any attribute on it. - else if ($attributes === TRUE) { + // Tell CKEditor the tag is allowed, as well as any attribute on it. The + // "style" and "class" attributes are handled separately by CKEditor: + // they are disallowed even if you specify it in the list of allowed + // attributes, unless you state specific values for them that are + // allowed. Or, in this case: any value for them is allowed. + elseif ($attributes === TRUE) { $setting[$tag] = array( 'attributes' => TRUE, 'styles' => TRUE, @@ -346,8 +350,8 @@ protected function generateAllowedContentSetting(Editor $editor) { $setting[$tag]['styles'] = $wildcard['style']; } else { - $allowed_styles = $get_allowed_attribute_values($attributes['style']); - if (isset($allowed_values)) { + $allowed_styles = $get_allowed_attribute_values($wildcard['style']); + if (isset($allowed_styles)) { $setting[$tag]['styles'] = $allowed_styles; } else { @@ -360,9 +364,9 @@ protected function generateAllowedContentSetting(Editor $editor) { $setting[$tag]['classes'] = $wildcard['class']; } else { - $allowed_styles = $get_allowed_attribute_values($attributes['class']); - if (isset($allowed_values)) { - $setting[$tag]['classes'] = $allowed_styles; + $allowed_classes = $get_allowed_attribute_values($wildcard['class']); + if (isset($allowed_classes)) { + $setting[$tag]['classes'] = $allowed_classes; } else { unset($setting[$tag]['classes']); @@ -372,7 +376,7 @@ protected function generateAllowedContentSetting(Editor $editor) { } } // Tell CKEditor the tag is allowed, along with some tags. - else if (is_array($attributes)) { + elseif (is_array($attributes)) { // CKEditor does not yet support blacklisting, so ignore those. // @todo Update this once http://dev.ckeditor.com/ticket/10276 lands. $attributes = array_filter($attributes, function($value) { diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php index 9655051..15228d2 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php @@ -147,6 +147,7 @@ function testGetJSSettings() { ), '*' => array( 'style' => FALSE, + 'class' => array('is-a-hipster-llama' => TRUE, 'and-more' => TRUE), 'data-*' => TRUE, ), 'del' => FALSE, @@ -159,7 +160,7 @@ function testGetJSSettings() { 'p' => array( 'attributes' => TRUE, 'styles' => FALSE, - 'classes' => TRUE, + 'classes' => 'is-a-hipster-llama,and-more', ), 'a' => array( 'attributes' => 'href,rel,class,target', @@ -169,7 +170,8 @@ function testGetJSSettings() { 'attributes' => 'class,property,rel', ), '*' => array( - 'attributes' => 'data-*', + 'attributes' => 'class,data-*', + 'classes' => 'is-a-hipster-llama,and-more', ), 'del' => array( 'attributes' => FALSE,