JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.4.1
[ckeditor.git] / _source / plugins / htmldataprocessor / plugin.js
index 24e4830..c431c03 100644 (file)
@@ -263,7 +263,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                defaultHtmlFilterRules.elements[ i ] = unprotectReadyOnly;\r
        }\r
 \r
-       var protectAttributeRegex = /<(?:a|area|img|input)[\s\S]*?\s((?:href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+)))/gi;\r
+       var protectAttributeRegex = /<((?:a|area|img|input)[\s\S]*?\s)((href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+)))([^>]*)>/gi,\r
+               findSavedSrcRegex = /\s_cke_saved_src\s*=/;\r
 \r
        var protectElementsRegex = /(?:<style(?=[ >])[^>]*>[\s\S]*<\/style>)|(?:<(:?link|meta|base)[^>]*>)/gi,\r
                encodedElementsRegex = /<cke:encoded>([^<]*)<\/cke:encoded>/gi;\r
@@ -275,7 +276,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
        function protectAttributes( html )\r
        {\r
-               return html.replace( protectAttributeRegex, '$& _cke_saved_$1' );\r
+               return html.replace( protectAttributeRegex, function( tag, beginning, fullAttr, attrName, end )\r
+                       {\r
+                               // We should not rewrite the _cke_saved_src attribute (#5218)\r
+                               if ( attrName == 'src' && findSavedSrcRegex.test( tag ) )\r
+                                       return tag;\r
+                               else\r
+                                       return '<' + beginning + fullAttr + ' _cke_saved_' + fullAttr + end + '>';\r
+                       });\r
        }\r
 \r
        function protectElements( html )\r