Skip to content

Commit abb150f

Browse files
committed
Merge branch 't/11508'
2 parents 31b7e1f + ab99c05 commit abb150f

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Fixed Issues:
1111
* [#11253](http://dev.ckeditor.com/ticket/11253): [IE] Fixed: Clipped upload button in [Enhanced Image](http://ckeditor.com/addon/image2) dialog.
1212
* [#11359](http://dev.ckeditor.com/ticket/11359): Standardized the way anchors are discovered by the [Link](http://ckeditor.com/addon/link) dialog.
1313
* [#11058](http://dev.ckeditor.com/ticket/11058): [IE8] Fixed: Error when deleting a row.
14+
* [#11508](http://dev.ckeditor.com/ticket/11508): Fixed: htmlDataProcessor discovering protected attributes within other attributes' values.
1415

1516
## CKEditor 4.3.2
1617

core/htmldataprocessor.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,23 @@
741741
//
742742

743743
var protectElementRegex = /<(a|area|img|input|source)\b([^>]*)>/gi,
744-
protectAttributeRegex = /\s(on\w+|href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi;
744+
// Be greedy while looking for protected attributes. This will let us avoid an unfortunate
745+
// situation when "nested attributes", which may appear valid, are also protected.
746+
// I.e. if we consider the following HTML:
747+
//
748+
// <img data-x="&lt;a href=&quot;X&quot;" />
749+
//
750+
// then the "non-greedy match" returns:
751+
//
752+
// 'href' => '&quot;X&quot;' // It's wrong! Href is not an attribute of <img>.
753+
//
754+
// while greedy match returns:
755+
//
756+
// 'data-x' => '&lt;a href=&quot;X&quot;'
757+
//
758+
// which, can be easily filtered out (#11508).
759+
protectAttributeRegex = /((?:\w|-)+)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi,
760+
protectAttributeNameRegex = /^(href|src|name)$/i;
745761

746762
// Note: we use lazy star '*?' to prevent eating everything up to the last occurrence of </style> or </textarea>.
747763
var protectElementsRegex = /(?:<style(?=[ >])[^>]*>[\s\S]*?<\/style>)|(?:<(:?link|meta|base)[^>]*>)/gi,
@@ -758,10 +774,8 @@
758774
return '<' + tag + attributes.replace( protectAttributeRegex, function( fullAttr, attrName ) {
759775
// Avoid corrupting the inline event attributes (#7243).
760776
// We should not rewrite the existed protected attributes, e.g. clipboard content from editor. (#5218)
761-
if ( !( /^on/ ).test( attrName ) && attributes.indexOf( 'data-cke-saved-' + attrName ) == -1 ) {
762-
fullAttr = fullAttr.slice( 1 ); // Strip the space.
777+
if ( protectAttributeNameRegex.test( attrName ) && attributes.indexOf( 'data-cke-saved-' + attrName ) == -1 )
763778
return ' data-cke-saved-' + fullAttr + ' data-cke-' + CKEDITOR.rnd + '-' + fullAttr;
764-
}
765779

766780
return fullAttr;
767781
} ) + '>';

0 commit comments

Comments
 (0)