Bartosz Dziewoński has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/322892

Change subject: mw.UploadWizardLicenseInput: Correct unguarded for...in
......................................................................

mw.UploadWizardLicenseInput: Correct unguarded for...in

A for...in loop will also interate over the properties of the
prototype of the object. If some other script adds custom properties
to Array.prototype or Object.prototype, we'll find them here,
`template[ '*' ]` will most likely be undefined and result in an
exception from mw.Title.

Instead, use a regular for loop. (Wrapping the body of the loop in a
hasOwnProperty() check would also work, but since we're iterating over
an array, this is nicer.)

Bug: T151220
Change-Id: I273b2921f7171754fe9ffac6a84cae7a3d10c05a
(cherry picked from commit 5b8016359f069f39b9fa2a867f2a9c6b2eb4eb49)
---
M resources/mw.UploadWizardLicenseInput.js
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard 
refs/changes/92/322892/1

diff --git a/resources/mw.UploadWizardLicenseInput.js 
b/resources/mw.UploadWizardLicenseInput.js
index de7942d..057c0f1 100644
--- a/resources/mw.UploadWizardLicenseInput.js
+++ b/resources/mw.UploadWizardLicenseInput.js
@@ -530,7 +530,7 @@
                                var templates = [],
                                        template, title, i;
 
-                               for ( i in result.parse.templates ) {
+                               for ( i = 0; i < result.parse.templates.length; 
i++ ) {
                                        template = result.parse.templates[ i ];
 
                                        // normalize templates to 
mw.Title.getPrefixedDb() format

-- 
To view, visit https://gerrit.wikimedia.org/r/322892
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I273b2921f7171754fe9ffac6a84cae7a3d10c05a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: wmf/1.29.0-wmf.3
Gerrit-Owner: Bartosz Dziewoński <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to