Properly handle script tags in dialog content
authorMatthias Schmidt <gravatronics@live.com>
Sun, 10 Jul 2016 12:36:55 +0000 (14:36 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 10 Jul 2016 12:37:26 +0000 (14:37 +0200)
wcfsetup/install/files/js/WoltLab/WCF/Ui/Dialog.js

index c98dfcd9e9614f6fe26c7ce10ff6a2c4f1d31a4f..373b79af8d8527d9942d7e78ecccdc2219161f75 100644 (file)
@@ -157,7 +157,7 @@ define(
                                if (typeof setupData.source === 'string') {
                                        var dialogElement = elCreate('div');
                                        elAttr(dialogElement, 'id', setupData.id);
-                                       dialogElement.innerHTML = setupData.source;
+                                       DomUtil.setInnerHtml(dialogElement, setupData.source);
                                        
                                        setupData.source = document.createDocumentFragment();
                                        setupData.source.appendChild(dialogElement);
@@ -306,7 +306,7 @@ define(
                                if (typeof html === 'string') {
                                        content = elCreate('div');
                                        content.id = id;
-                                       content.innerHTML = html;
+                                       DomUtil.setInnerHtml(content, html);
                                }
                                else if (html instanceof DocumentFragment) {
                                        if (html.children[0].nodeName !== 'div' || html.childElementCount > 1) {
@@ -366,17 +366,7 @@ define(
                                data.content.innerHTML = '';
                                
                                var content = elCreate('div');
-                               content.innerHTML = html;
-                               
-                               var scripts = elBySelAll('script', content);
-                               for (var i = 0, length = scripts.length; i < length; i++) {
-                                       var script = scripts[i];
-                                       var newScript = elCreate('script');
-                                       newScript.innerHTML = script.innerHTML;
-                                       content.appendChild(newScript);
-                                       
-                                       elRemove(script);
-                               }
+                               DomUtil.setInnerHtml(content, html);
                                
                                data.content.appendChild(content);
                        }