Skip to content

fix(core): fall back to raw XML when pretty-printing fails - #363

Open
C1-BA-B1-F3 wants to merge 1 commit into
geopython:masterfrom
C1-BA-B1-F3:fix/pretty-print-fallback
Open

C1-BA-B1-F3 wants to merge 1 commit into
geopython:masterfrom
C1-BA-B1-F3:fix/pretty-print-fallback

Conversation

@C1-BA-B1-F3

Copy link
Copy Markdown

Summary

minidom.parseString raises ExpatError when the rendered XML contains unescaped special characters (e.g. an & in a creation date), crashing the whole metadata generation with no output.

xml.parsers.expat.ExpatError: not well-formed (invalid token): line 182, column 42

Fix

Catch the error in pretty_print, log a warning, and return the raw XML so the user still gets usable output.

Test plan

  • Valid XML still pretty-prints.
  • Invalid XML (unescaped &) returns raw XML with a logged warning instead of raising.

Fixes #336

minidom.parseString raises ExpatError on XML with unescaped special
characters (e.g. an '&' in a creation date), crashing the whole
metadata generation. Catch the error, log it, and return the raw XML
so the user still gets usable output.

Fixes geopython#336

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pygeometa.core:pretty-printing XML fails with illegal character - if creation date has '&'

1 participant