Skip to content

Commit a38bf64

Browse files
committed
Filter invalid KML file names
1 parent 0fb35d9 commit a38bf64

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

RELEASE-NOTES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ different releases and which versions of PHP and MediaWiki they support, see the
33
[platform compatibility tables](INSTALL.md#platform-compatibility-and-release-status).
44

55

6+
## Maps 7.12.2
7+
8+
Released on December 9th, 2019.
9+
10+
* Invalid KML file names are no longer passed to Google Maps
11+
612
## Maps 7.12.1
713

814
Released on December 9th, 2019.

extension.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Maps",
3-
"version": "7.12.1",
3+
"version": "7.12.2",
44

55
"author": [
66
"[https://www.entropywins.wtf/mediawiki Jeroen De Dauw]",

src/GoogleMapsService.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,18 @@ public function getParameterInfo(): array {
214214
'message' => 'maps-par-kml',
215215
'islist' => true,
216216
'post-format' => function( array $kmlFileNames ) {
217-
return array_map(
218-
function( string $fileName ) {
219-
return wfExpandUrl( MapsFunctions::getFileUrl( $fileName ) );
220-
},
221-
$kmlFileNames
217+
return array_values(
218+
array_filter(
219+
array_map(
220+
function( string $fileName ) {
221+
return wfExpandUrl( MapsFunctions::getFileUrl( $fileName ) );
222+
},
223+
$kmlFileNames
224+
),
225+
function( string $fileName ) {
226+
return $fileName !== '';
227+
}
228+
)
222229
);
223230
}
224231
];

tests/Integration/Parser/DisplayMapTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,4 +245,13 @@ public function testGeoJsonSourceForPage() {
245245
);
246246
}
247247

248+
public function testGoogleMapsKmlFiltersInvalidFileNames() {
249+
$this->assertContains(
250+
'"kml":["ValidFile.kml"],',
251+
$this->parse(
252+
"{{#display_map:service=google|kml=, ,ValidFile.kml ,}}"
253+
)
254+
);
255+
}
256+
248257
}

0 commit comments

Comments
 (0)