Improved detection of pasted HTML
authorAlexander Ebert <ebert@woltlab.com>
Fri, 3 Nov 2017 13:48:11 +0000 (14:48 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 3 Nov 2017 13:48:11 +0000 (14:48 +0100)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabPaste.js

index 0d86aebdda5dc6378fe56211f80a263e16438b4c..caa90421c24ff8d8f255a14be8ba6aa4c131238d 100644 (file)
@@ -98,7 +98,7 @@ $.Redactor.prototype.WoltLabPaste = function() {
                                                pastedHtml = e.originalEvent.clipboardData.getData('text/html');
                                                
                                                // remove document fragments
-                                               if (pastedHtml.match(/^<html>[\s\S]*?<body>([\s\S]+)<\/body>\s*<\/html>$/)) {
+                                               if (pastedHtml.trim().match(/^<html[^>]*>[\s\S]*?<body[^>]*>([\s\S]+)<\/body>[\s\S]*?<\/html>$/)) {
                                                        pastedHtml = RegExp.$1.replace(/^\s*(?:<!--StartFragment-->)(.+)(?:<!--EndFragment-->)?\s*$/, '$1');
                                                }
                                        }