Sbisson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/205850
Change subject: getTitle handles invalid URI
......................................................................
getTitle handles invalid URI
When an anchor's href attribute is
javascript:void(0); new mv.Uri(href) throws
"Bad constructor arguments".
This causes a ResourceLoader exception and
prevents all browser tests from running
on the Flow project.
Change-Id: Iee5f857210cbff3c217a05986fac59ba0bef7268
---
M resources/ext.popups.core.js
M tests/qunit/ext.popups.core.test.js
2 files changed, 10 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups
refs/changes/50/205850/1
diff --git a/resources/ext.popups.core.js b/resources/ext.popups.core.js
index 512f50d..2793110 100644
--- a/resources/ext.popups.core.js
+++ b/resources/ext.popups.core.js
@@ -155,8 +155,14 @@
* @return {string|undefined}
*/
mw.popups.getTitle = function ( href ) {
- var title, titleRegex, matches,
- linkHref = new mw.Uri( href );
+ var title, titleRegex, matches, linkHref;
+
+ try {
+ linkHref = new mw.Uri( href );
+ } catch (exception) {
+ // href is not a uri ( could be javascript:void(0); )
+ return undefined;
+ }
// External links
if ( linkHref.host !== location.hostname ) {
diff --git a/tests/qunit/ext.popups.core.test.js
b/tests/qunit/ext.popups.core.test.js
index 301cab8..a95b9cb 100644
--- a/tests/qunit/ext.popups.core.test.js
+++ b/tests/qunit/ext.popups.core.test.js
@@ -20,7 +20,8 @@
[ '/w/Foo?title=Foo&action=edit', undefined ],
[ '/w/index.php?title=%E6%B8%AC%E8%A9%A6', '測試' ],
[ '/w/index.php?oldid=1', undefined ],
- [ '/Foo', undefined ]
+ [ '/Foo', undefined ],
+ [ 'javascript:void(0);', undefined ]
];
for ( i = 0; i < cases.length; i++ ) {
--
To view, visit https://gerrit.wikimedia.org/r/205850
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iee5f857210cbff3c217a05986fac59ba0bef7268
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: master
Gerrit-Owner: Sbisson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits