From a1d7aad40119cd3f2bc970fc7ce10625d0da7106 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 13 Mar 2012 17:16:09 -0400 Subject: [PATCH 1/1] fix writing of kml file It just didn't work, but also, it didn't use writefile, which is not desirable for security. Fixed both issues. Also removed some unnecessary debug messages. --- IkiWiki/Plugin/osm.pm | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/IkiWiki/Plugin/osm.pm b/IkiWiki/Plugin/osm.pm index 2b5d0d5f1..47c752881 100644 --- a/IkiWiki/Plugin/osm.pm +++ b/IkiWiki/Plugin/osm.pm @@ -341,8 +341,7 @@ sub writejson($;$) { "geometry" => { "type" => "LineString", "coordinates" => $linestring }); push @{$geojson{'features'}}, \%json; } - debug('writing pois file pois.json in ' . $config{destdir} . "/$map"); - writefile("pois.json",$config{destdir} . "/$map",to_json(\%geojson)); + writefile("pois.json", $config{destdir} . "/$map", to_json(\%geojson)); } } @@ -352,7 +351,6 @@ sub writekml($;$) { eval q{use XML::Writer}; error $@ if $@; foreach my $map (keys %waypoints) { - debug("writing pois file pois.kml in " . $config{destdir} . "/$map"); =pod Sample placemark: @@ -388,10 +386,9 @@ Sample style: =cut - use IO::File; - my $output = IO::File->new(">".$config{destdir} . "/$map/pois.kml"); - - my $writer = XML::Writer->new( OUTPUT => $output, DATA_MODE => 1, ENCODING => 'UTF-8'); + my $output; + my $writer = XML::Writer->new( OUTPUT => \$output, + DATA_MODE => 1, ENCODING => 'UTF-8'); $writer->xmlDecl(); $writer->startTag("kml", "xmlns" => "http://www.opengis.net/kml/2.2"); @@ -454,7 +451,8 @@ Sample style: } $writer->endTag(); $writer->end(); - $output->close(); + + writefile("pois.kmp", $config{destdir} . "/$map", $output); } } @@ -472,8 +470,7 @@ sub writecsvs($;$) { $options{'icon'} . "\n"; $poisf .= $line; } - debug("writing pois file pois.txt in " . $config{destdir} . "/$map"); - writefile("pois.txt",$config{destdir} . "/$map",$poisf); + writefile("pois.txt", $config{destdir} . "/$map", $poisf); } } -- 2.45.0