Gerrit Patch Uploader has uploaded a new change for review. https://gerrit.wikimedia.org/r/242815
Change subject: mediawiki.Uri: Support names of Object prototypes as keys in query string ...................................................................... mediawiki.Uri: Support names of Object prototypes as keys in query string Bug: T114344 Change-Id: I7a58204c98d7a490906c6a23620e9f24ebb3db0a --- M resources/src/mediawiki/mediawiki.Uri.js M tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js 2 files changed, 14 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/15/242815/1 diff --git a/resources/src/mediawiki/mediawiki.Uri.js b/resources/src/mediawiki/mediawiki.Uri.js index 29b224e..77bc5e4 100644 --- a/resources/src/mediawiki/mediawiki.Uri.js +++ b/resources/src/mediawiki/mediawiki.Uri.js @@ -298,7 +298,7 @@ // If overrideKeys, always (re)set top level value. // If not overrideKeys but this key wasn't set before, then we set it as well. - if ( options.overrideKeys || q[ k ] === undefined ) { + if ( options.overrideKeys || !Object.prototype.hasOwnProperty.call( q, k ) ) { q[ k ] = v; // Use arrays if overrideKeys is false and key was already seen before diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js index 51374bd..addee48 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js @@ -60,7 +60,7 @@ } ); } ); - QUnit.test( 'Constructor( String[, Object ] )', 10, function ( assert ) { + QUnit.test( 'Constructor( String[, Object ] )', 11, function ( assert ) { var uri; uri = new mw.Uri( 'http://www.example.com/dir/?m=foo&m=bar&n=1', { @@ -132,6 +132,18 @@ strictMode: false } ); assert.equal( uri.toString(), 'http://example.com/bar/baz', 'normalize URI without protocol or // in loose mode' ); + + uri = new mw.Uri( 'http://example.com/index.php?key=key&hasOwnProperty=hasOwnProperty&constructor=constructor&watch=watch' ); + assert.deepEqual( + uri.query, + { + 'key': 'key', + 'constructor': 'constructor', + 'hasOwnProperty': 'hasOwnProperty', + 'watch': 'watch' + }, + 'Keys in query strings support names of Object prototypes (bug T114344)' + ); } ); QUnit.test( 'Constructor( Object )', 3, function ( assert ) { -- To view, visit https://gerrit.wikimedia.org/r/242815 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7a58204c98d7a490906c6a23620e9f24ebb3db0a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits