Escape ampersands and angle brackets from track title in GPX.

This commit is contained in:
voussoir 2023-11-30 17:41:21 -08:00
parent 52dbae2f41
commit b84185ea4e

View file

@ -97,8 +97,9 @@ data class Track (
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
> >
""".trimIndent()) """.trimIndent())
val name_escaped = this.name.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
write("\t<metadata>") write("\t<metadata>")
write("\t\t<name>${this.name}</name>") write("\t\t<name>${name_escaped}</name>")
write("\t\t<application>${BuildConfig.APPLICATION_ID} ${BuildConfig.VERSION_NAME}</application>") write("\t\t<application>${BuildConfig.APPLICATION_ID} ${BuildConfig.VERSION_NAME}</application>")
write("\t\t<device>${this.device_id}</device>") write("\t\t<device>${this.device_id}</device>")
write("\t</metadata>") write("\t</metadata>")