Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Links in XML not properly encoded #283

Open
krzys-h opened this issue Jul 27, 2024 · 0 comments
Open

Links in XML not properly encoded #283

krzys-h opened this issue Jul 27, 2024 · 0 comments

Comments

@krzys-h
Copy link

krzys-h commented Jul 27, 2024

I'm trying to alter a .gpx file which contains a link along the lines of:

<?xml version="1.0" encoding="UTF-8"?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" version="1.1">
  <metadata>
    <link href="https://example.com/?this=is&amp;an=example">
      <text>some text</text>
    </link>
  </metadata>
</gpx>

After modifying the file using gpxpy and exporting with to_xml(), this turns into:

<?xml version="1.0" encoding="UTF-8"?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" version="1.1">
  <metadata>
    <link href="https://example.com/?this=is&an=example">
      <text>some text</text>
    </link>
  </metadata>
</gpx>

which is not valid XML (as even the GitHub markdown highlighting shows) - unlike HTML5, you need to always encode the &amp;. This causes the file to fail to import in gpxpod (and maybe other gpx viewers as well)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant