Repository navigation
Leave out invalid XML characters and write single line breaks in GPX/… - #1330
Merged
AgreeDK merged 1 commit intoNov 18, 2026
Merged
Conversation
…GGZ exports The GPX/GGZ export wrote text exactly as stored in the database, which caused two problems: * Control characters that XML 1.0 doesn't allow (e.g. \x02 in Adventure Lab descriptions imported from GSAK) were written as they are. A single one makes the whole file invalid XML, and strict readers such as c:geo reject it. * Text with CR LF line breaks (from GSAK and geocaching.com) came out as CR CR LF in a text-mode file on Windows. Parsers read that as two line breaks, so every multi-line log, user note and description got empty lines between its lines. _xml_chunk(), which serializes every element of the GPX, GGZ and LOC export, now removes the characters XML 1.0 doesn't allow (C0 controls except tab, LF and CR; U+FFFE, U+FFFF; lone surrogates) and writes line breaks in the text as LF. Parsers read CR LF and a lone CR as LF anyway, so the text is unchanged; a text-mode file on Windows now has a single CR LF per line break, as GSAK's own export does. The line breaks are fixed in the writer instead of opening the file with newline="", because macros save through safe_write_stream(), which also opens the file in text mode and is used for every other file a macro writes. This way the export dialog, Send to GPS (including MTP) and macros are all fixed. fixes OpenSAK-Org#1329
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…GGZ exports
The GPX/GGZ export wrote text exactly as stored in the database, which caused two problems:
_xml_chunk(), which serializes every element of the GPX, GGZ and LOC export, now removes the characters XML 1.0 doesn't allow (C0 controls except tab, LF and CR; U+FFFE, U+FFFF; lone surrogates) and writes line breaks in the text as LF. Parsers read CR LF and a lone CR as LF anyway, so the text is unchanged; a text-mode file on Windows now has a single CR LF per line break, as GSAK's own export does.
The line breaks are fixed in the writer instead of opening the file with newline="", because macros save through safe_write_stream(), which also opens the file in text mode and is used for every other file a macro writes. This way the export dialog, Send to GPS (including MTP) and macros are all fixed.
fixes #1329