mendhak / waveshare-epaper-display

At-a-glance dashboard for Raspberry Pi with a Waveshare ePaper 7.5 Inch HAT. Date/Time, Weather, Alerts, Google/Outlook Calendar
https://code.mendhak.com/raspberrypi-epaper-dashboard/
438 stars 65 forks source link

XML Parser can't resolve '&' in calendar event #69

Closed chrisrieth closed 8 months ago

chrisrieth commented 8 months ago

Back again, this time I think with an actual issue. I'm investigating an approach to resolving, but I wanted to file it here in case you've run into this. I started having issues yesterday where I noticed my calendar not updating. Debug / logs isolate this down to the XML. Originally I thought this was my modifications to the layout, but I think I've isolated the issue to calendar entries with & within the title.

Issue

Calendar entry with & character fails to pass XML parsing step

Example

[utility.py:61] update_svg() - CAL_DESC_8 -> Lunch & Learn!

Result / Error

EXPORT TO PNG
---------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.9/xml/etree/ElementTree.py", line 1720, in feed
    self.parser.Parse(data, False)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 309, column 325

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/waveshare-epaper-display/.venv/bin/cairosvg", line 8, in <module>
    sys.exit(main())
  File "/home/pi/waveshare-epaper-display/.venv/lib/python3.9/site-packages/cairosvg/__main__.py", line 78, in main
    SURFACES[output_format.upper()].convert(**kwargs)
  File "/home/pi/waveshare-epaper-display/.venv/lib/python3.9/site-packages/cairosvg/surface.py", line 127, in convert
    tree = Tree(
  File "/home/pi/waveshare-epaper-display/.venv/lib/python3.9/site-packages/cairosvg/parser.py", line 390, in __init__
    tree = ElementTree.fromstring(
  File "/home/pi/waveshare-epaper-display/.venv/lib/python3.9/site-packages/defusedxml/common.py", line 126, in fromstring
    parser.feed(text)
  File "/usr/lib/python3.9/xml/etree/ElementTree.py", line 1722, in feed
    self._raiseerror(v)
  File "/usr/lib/python3.9/xml/etree/ElementTree.py", line 1629, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 309, column 325
chrisrieth commented 8 months ago

Just caught issue #39 - checking out my XML and testing CDATA additions!

chrisrieth commented 8 months ago

That did it! Closing!