From df435dda49d4190291d9e5e3837052b9a401dd27 Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Wed, 3 Oct 2012 09:49:01 +0800 Subject: [PATCH] MDL-35754 libraries: openpopup() does not fail when window name is not set --- lib/javascript-static.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/javascript-static.js b/lib/javascript-static.js index bf5ecf21e72..84bf7bbceb5 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -1212,9 +1212,12 @@ function openpopup(event, args) { } } - // Cleans window name because IE does not support funky ones. + // Make sure the name argument is set and valid. var nameregex = /[^a-z0-9_]/i; - if (args.name.match(nameregex)) { + if (typeof args.name !== 'string') { + args.name = '_blank'; + } else if (args.name.match(nameregex)) { + // Cleans window name because IE does not support funky ones. args.name = args.name.replace(nameregex, '_'); if (M.cfg.developerdebug) { alert('DEVELOPER NOTICE: Invalid \'name\' passed to openpopup()');