MDL-31499 Javascript: Handle invalid window names in openpopup
authorFrederic Massart <fred@moodle.com>
Thu, 13 Sep 2012 08:51:45 +0000 (16:51 +0800)
committerFrederic Massart <fred@moodle.com>
Mon, 24 Sep 2012 07:24:30 +0000 (15:24 +0800)
lib/javascript-static.js

index 812fe07..068fb98 100644 (file)
@@ -1178,6 +1178,15 @@ function openpopup(event, args) {
         }
     }
 
+    // Cleans window name because IE does not support funky ones.
+    var nameregex = /[^a-z0-9_]/i;
+    if (args.name.match(nameregex)) {
+        args.name = args.name.replace(nameregex, '_');
+        if (M.cfg.developerdebug) {
+            alert('DEVELOPER NOTICE: Invalid \'name\' passed to openpopup()');
+        }
+    }
+
     var fullurl = args.url;
     if (!args.url.match(/https?:\/\//)) {
         fullurl = M.cfg.wwwroot + args.url;