jenkins-bot has submitted this change and it was merged.
Change subject: Fix GeoData validation fail observed in the wild
......................................................................
Fix GeoData validation fail observed in the wild
Change-Id: I9d565e6f138d2b741d16c4c0eafffcde54581e04
---
M GeoData.body.php
M tests/ParseCoordTest.php
2 files changed, 9 insertions(+), 9 deletions(-)
Approvals:
MaxSem: Verified; Looks good to me, approved
jenkins-bot: Verified
diff --git a/GeoData.body.php b/GeoData.body.php
index 71747e9..614ebe6 100644
--- a/GeoData.body.php
+++ b/GeoData.body.php
@@ -99,10 +99,6 @@
$alreadyFractional = false;
for ( $i = 0; $i < $count; $i++ ) {
- // 20° 15.5' 20" is wrong
- if ( $alreadyFractional ) {
- return false;
- }
$part = $parts[$i];
if ( $i > 0 && $i == $count - 1 ) {
$suffix = self::parseSuffix( $part, $coordInfo
);
@@ -116,6 +112,10 @@
return false;
}
}
+ // 20° 15.5' 20" is wrong
+ if ( $alreadyFractional ) {
+ return false;
+ }
if ( !is_numeric( $part ) ) {
$part = $wgContLang->parseFormattedNumber(
$part );
}
diff --git a/tests/ParseCoordTest.php b/tests/ParseCoordTest.php
index 9efc087..fb7a01c 100644
--- a/tests/ParseCoordTest.php
+++ b/tests/ParseCoordTest.php
@@ -32,8 +32,8 @@
array( array( -20, 30, 40, 45 ), new Coord( -20.5,
40.75 ) ),
array( array( 20, 30, 40, 40, 45, 55 ), new Coord(
20.511111111111, 40.765277777778 ) ),
// NESW
- array( array( 20, 'N', 30, 'E' ), new Coord( 20, 30 ) ),
- array( array( 20, 'N', 30, 'W' ), new Coord( 20, -30 )
),
+ array( array( 20.1, 'N', 30, 'E' ), new Coord( 20.1, 30
) ),
+ array( array( 20, 'N', 30.5, 'W' ), new Coord( 20,
-30.5 ) ),
array( array( 20, 'S', 30, 'E' ), new Coord( -20, 30 )
),
array( array( 20, 'S', 30, 'W' ), new Coord( -20, -30 )
),
array( array( 20, 30, 40, 'S', 40, 45, 55, 'E' ), new
Coord( -20.511111111111, 40.765277777778 ) ),
@@ -71,9 +71,9 @@
array( array( 10, -1, 20, 0 ), false ),
array( array( 25, 60, 10, 0 ), false ),
array( array( 25, 0, 0, 10, 0, 60 ), false ),
- // @todo: only the last component of the coordinate
should be non-integer
- //array( array( 10.5, 0, 20, 0 ), false ),
- //array( array( 10, 30.5, 0, 20, 0, 0 ), false ),
+ // only the last component of the coordinate should be
non-integer
+ array( array( 10.5, 0, 20, 0 ), false ),
+ array( array( 10, 30.5, 0, 20, 0, 0 ), false ),
// coordinate validation and normalisation (non-Earth)
array( array( 10, 20 ), new Coord( 10, 20 ), 'mars' ),
array( array( 110, 20 ), false, 'mars' ),
--
To view, visit https://gerrit.wikimedia.org/r/61962
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9d565e6f138d2b741d16c4c0eafffcde54581e04
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GeoData
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits