Skip to content

Commit

Permalink
Improve escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenDeDauw committed Nov 20, 2018
1 parent 3a6c277 commit afd8e17
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Presentation/KmlFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ private function locationToKmlPlacemark( Location $location ): string {
// TODO: escaping?
$description = '<description><![CDATA[ ' . $location->getText() . ']]></description>';

$coordinates = '<coordinates>' . htmlspecialchars( $this->getCoordinateString( $location ) ) . '</coordinates>';
$coordinates = '<coordinates>'
. $this->escapeValue( $this->getCoordinateString( $location ) )
. '</coordinates>';

return <<<EOT
<Placemark>
Expand All @@ -68,4 +70,8 @@ private function getCoordinateString( Location $location ): string {
. ',0';
}

private function escapeValue( string $value ): string {
return htmlspecialchars( $value, ENT_NOQUOTES );
}

}

0 comments on commit afd8e17

Please sign in to comment.