jenkins-bot has submitted this change and it was merged.

Change subject: Fix NaN location input
......................................................................


Fix NaN location input

There were edgecases where input could not be numeric, e.g.:
* '.'
* '88 . 123'
The regular expressions need to accept '.' as part of a number, but
a '.' can never exist in isolation.
NaNs should now no longer happen, but just to be sure, we're now
also explicitly checking for NaN.

Bug: T146353
Change-Id: Ide45287e710a17544a7c55201d370e52e560f6e3
---
M resources/details/uw.LocationDetailsWidget.js
1 file changed, 4 insertions(+), 4 deletions(-)

Approvals:
  Bartosz Dziewoński: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/resources/details/uw.LocationDetailsWidget.js 
b/resources/details/uw.LocationDetailsWidget.js
index b68911c..0727fc6 100644
--- a/resources/details/uw.LocationDetailsWidget.js
+++ b/resources/details/uw.LocationDetailsWidget.js
@@ -62,11 +62,11 @@
                // input is invalid if the coordinates are out of bounds, or if 
the
                // coordinates that were derived from the input are 0, without 
a 0 even
                // being present in the input
-               if ( latNum > 90 || latNum < -90 || ( latNum === 0 && 
latInput.indexOf( '0' ) < 0 && latInput !== '' ) ) {
+               if ( latNum > 90 || latNum < -90 || ( latNum === 0 && 
latInput.indexOf( '0' ) < 0 && latInput !== '' ) || isNaN( latNum ) ) {
                        errors.push( mw.message( 'mwe-upwiz-error-latitude' ) );
                }
 
-               if ( lonNum > 180 || lonNum < -180 || ( lonNum === 0 && 
lonInput.indexOf( '0' ) < 0 && lonInput !== '' ) ) {
+               if ( lonNum > 180 || lonNum < -180 || ( lonNum === 0 && 
lonInput.indexOf( '0' ) < 0 && lonInput !== '' ) || isNaN( lonNum ) ) {
                        errors.push( mw.message( 'mwe-upwiz-error-longitude' ) 
);
                }
 
@@ -168,11 +168,11 @@
                        parts, value;
 
                // fix commonly used character alternatives
-               coordinate = coordinate.replace( ',', '.' );
+               coordinate = coordinate.replace( /\s*[,\.]\s*/, '.' );
 
                // convert degrees, minutes, seconds (or degrees & decimal 
minutes) to
                // decimal degrees
-               // there's can be a lot of variation in the notation, so let's 
only
+               // there can be a lot of variation in the notation, so let's 
only
                // focus on "groups of digits" (and not whether e.g. ″ or " is 
used)
                parts = coordinate.match( 
/(-?[0-9\.]+)[^0-9\.]+([0-9\.]+)(?:[^0-9\.]+([0-9\.]+))?/ );
                if ( parts ) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ide45287e710a17544a7c55201d370e52e560f6e3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <mmul...@wikimedia.org>
Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to