badstreff / git2jss

Easily sync your scripts and EA's from a git repo with the JSS
MIT License
89 stars 56 forks source link

ElementTree errors on parsing "&" #23

Open cybertunnel opened 5 years ago

cybertunnel commented 5 years ago

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 commented 5 years ago

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

badstreff commented 5 years ago

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?

cybertunnel commented 5 years ago

Sure thing, will test now

cybertunnel commented 5 years ago

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

badstreff commented 5 years ago

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. ;)

Kurara commented 3 years ago

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.