Skip to content

Commit

Permalink
Filter invalid KML file names
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenDeDauw committed Dec 9, 2019
1 parent 0fb35d9 commit a38bf64
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
6 changes: 6 additions & 0 deletions RELEASE-NOTES.md
Expand Up @@ -3,6 +3,12 @@ different releases and which versions of PHP and MediaWiki they support, see the
[platform compatibility tables](INSTALL.md#platform-compatibility-and-release-status).


## Maps 7.12.2

Released on December 9th, 2019.

* Invalid KML file names are no longer passed to Google Maps

## Maps 7.12.1

Released on December 9th, 2019.
Expand Down
2 changes: 1 addition & 1 deletion extension.json
@@ -1,6 +1,6 @@
{
"name": "Maps",
"version": "7.12.1",
"version": "7.12.2",

"author": [
"[https://www.entropywins.wtf/mediawiki Jeroen De Dauw]",
Expand Down
17 changes: 12 additions & 5 deletions src/GoogleMapsService.php
Expand Up @@ -214,11 +214,18 @@ public function getParameterInfo(): array {
'message' => 'maps-par-kml',
'islist' => true,
'post-format' => function( array $kmlFileNames ) {
return array_map(
function( string $fileName ) {
return wfExpandUrl( MapsFunctions::getFileUrl( $fileName ) );
},
$kmlFileNames
return array_values(
array_filter(
array_map(
function( string $fileName ) {
return wfExpandUrl( MapsFunctions::getFileUrl( $fileName ) );
},
$kmlFileNames
),
function( string $fileName ) {
return $fileName !== '';
}
)
);
}
];
Expand Down
9 changes: 9 additions & 0 deletions tests/Integration/Parser/DisplayMapTest.php
Expand Up @@ -245,4 +245,13 @@ public function testGeoJsonSourceForPage() {
);
}

public function testGoogleMapsKmlFiltersInvalidFileNames() {
$this->assertContains(
'"kml":["ValidFile.kml"],',
$this->parse(
"{{#display_map:service=google|kml=, ,ValidFile.kml ,}}"
)
);
}

}

0 comments on commit a38bf64

Please sign in to comment.