Index: trunk/extensions/Maps/Includes/Maps_CoordinateParser.php |
— | — | @@ -179,6 +179,8 @@ |
180 | 180 | * @return string The normalized version of the provided coordinates. |
181 | 181 | */ |
182 | 182 | protected static function normalizeCoordinates( $coordinates ) { |
| 183 | + $coordinates = self::removeInvalidChars( $coordinates ); |
| 184 | + |
183 | 185 | $coordinates = str_replace( ' ', '', $coordinates ); |
184 | 186 | |
185 | 187 | $coordinates = str_replace( array( '°', '°' ), Maps_GEO_DEG, $coordinates ); |
— | — | @@ -190,6 +192,27 @@ |
191 | 193 | } |
192 | 194 | |
193 | 195 | /** |
| 196 | + * Returns a string with control characters and characters with ascii values above 126 removed. |
| 197 | + * |
| 198 | + * @param string $string Yeah, it's a string, seriously! |
| 199 | + * |
| 200 | + * @return string |
| 201 | + */ |
| 202 | + protected static function removeInvalidChars( $string ) { |
| 203 | + $filtered = array(); |
| 204 | + |
| 205 | + foreach ( str_split( $string ) as $character ) { |
| 206 | + $asciiValue = ord( $character ); |
| 207 | + |
| 208 | + if ( $asciiValue > 31 and $asciiValue < 127 ) { |
| 209 | + $filtered[] = $character; |
| 210 | + } |
| 211 | + } |
| 212 | + |
| 213 | + return implode( '', $filtered ); |
| 214 | + } |
| 215 | + |
| 216 | + /** |
194 | 217 | * Formats a single non-directional float coordinate in the given notation. |
195 | 218 | * |
196 | 219 | * @param string $coordinate The coordinate to be formatted. |