git2jss icon indicating copy to clipboard operation
git2jss copied to clipboard

ElementTree errors on parsing "&"

Open cybertunnel opened this issue 6 years ago • 6 comments

Receive the error: File "/usr/local/lib/python3.6/xml/etree/ElementTree.py", line 1314, in XML parser.feed(text) xml.etree.ElementTree.ParseError: reference to invalid character number: line 35, column 20

While trying to download and/or parse our scripts. It seems to be only breaking on &. I have been doing some research on how to mitigate this. The only thing I could see is to read the XML for each line and handle the & before the ElementTree gets it.

cybertunnel avatar Dec 21 '18 16:12 cybertunnel

Figured it out, have to replace any & with &. I will do a PR with my fix :)

cybertunnel avatar Dec 21 '18 16:12 cybertunnel

I think this issue may already be fixed in the dev branch but not merged in. Can you test the dev branch and see if it is still broken?

badstreff avatar Dec 21 '18 17:12 badstreff

Sure thing, will test now

cybertunnel avatar Dec 21 '18 17:12 cybertunnel

It is the same file in tools/, I am looking in the dev branch. Is there another branch the might have this fix?

cybertunnel avatar Dec 21 '18 17:12 cybertunnel

Nope, I recall a fix for something similar to this made in the past. Looks like this is still an issue. I'm definitely willing to take you up on that offer for a PR. ;)

badstreff avatar Jan 24 '19 20:01 badstreff

Figured it out, have to replace any & with &. I will do a PR with my fix :)

In fact, the library xml doesn't read "&". If you see in its code https://lxml.de/api/xml.etree.ElementTree-pysrc.html line 1061 it escapes "&" before writing it into xml.

Kurara avatar Sep 21 '20 09:09 Kurara