JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.3
[ckeditor.git] / _source / plugins / htmldataprocessor / plugin.js
index ad6fa47..ecf87ed 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -44,14 +44,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        typeof extendEmptyBlock == 'function' && ( extendEmptyBlock( block ) === false ) ) )\r
                        return false;\r
 \r
-        // 1. For IE version >=8,  empty blocks are displayed correctly themself in wysiwiyg;\r
-        // 2. For the rest, at least table cell and list item need no filler space.\r
-        // (#6248)\r
-        if ( fromSource && CKEDITOR.env.ie &&\r
-                ( document.documentMode > 7\r
-                || block.name in CKEDITOR.dtd.tr\r
-                || block.name in CKEDITOR.dtd.$listItem ) )\r
-            return false;\r
+       // 1. For IE version >=8,  empty blocks are displayed correctly themself in wysiwiyg;\r
+       // 2. For the rest, at least table cell and list item need no filler space.\r
+       // (#6248)\r
+       if ( fromSource && CKEDITOR.env.ie &&\r
+               ( document.documentMode > 7\r
+                       || block.name in CKEDITOR.dtd.tr\r
+                       || block.name in CKEDITOR.dtd.$listItem ) )\r
+               return false;\r
 \r
                var lastChild = lastNoneSpaceChild( block );\r
 \r
@@ -289,7 +289,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
        }\r
 \r
        var protectElementRegex = /<(a|area|img|input)\b([^>]*)>/gi,\r
-               protectAttributeRegex = /\b(href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi;\r
+               protectAttributeRegex = /\b(on\w+|href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi;\r
 \r
        var protectElementsRegex = /(?:<style(?=[ >])[^>]*>[\s\S]*<\/style>)|(?:<(:?link|meta|base)[^>]*>)/gi,\r
                encodedElementsRegex = /<cke:encoded>([^<]*)<\/cke:encoded>/gi;\r
@@ -305,9 +305,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                {\r
                        return '<' +  tag + attributes.replace( protectAttributeRegex, function( fullAttr, attrName )\r
                        {\r
+                               // Avoid corrupting the inline event attributes (#7243).\r
                                // We should not rewrite the existed protected attributes, e.g. clipboard content from editor. (#5218)\r
-                               if ( attributes.indexOf( 'data-cke-saved-' + attrName ) == -1 )\r
-                                       return ' data-cke-saved-' + fullAttr + ' ' + fullAttr;\r
+                               if ( !( /^on/ ).test( attrName ) && attributes.indexOf( 'data-cke-saved-' + attrName ) == -1 )\r
+                                       return ' data-cke-saved-' + fullAttr + ' data-cke-' + CKEDITOR.rnd + '-' + fullAttr;\r
 \r
                                return fullAttr;\r
                        }) + '>';\r
@@ -515,10 +516,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        // Call the browser to help us fixing a possibly invalid HTML\r
                        // structure.\r
                        var div = new CKEDITOR.dom.element( 'div' );\r
+\r
                        // Add fake character to workaround IE comments bug. (#3801)\r
                        div.setHtml( 'a' + data );\r
                        data = div.getHtml().substr( 1 );\r
 \r
+                       // Restore shortly protected attribute names.\r
+                       data = data.replace( new RegExp( ' data-cke-' + CKEDITOR.rnd + '-', 'ig' ), ' ' );\r
+\r
                        // Unprotect "some" of the protected elements at this point.\r
                        data = unprotectElementNames( data );\r
 \r