Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add support for very big event #300

Closed
aaujon opened this issue Mar 8, 2023 · 5 comments · Fixed by #301
Closed

Add support for very big event #300

aaujon opened this issue Mar 8, 2023 · 5 comments · Fixed by #301

Comments

@aaujon
Copy link

aaujon commented Mar 8, 2023

Hi,

The current code doesn't work with events with very big content, exception I get is :
Traceback (most recent call last): File "/home/arnaud/.local/lib/python3.10/site-packages/caldav/davclient.py", line 72, in __init__ self.tree = etree.XML( File "src/lxml/etree.pyx", line 3231, in lxml.etree.XML File "src/lxml/parser.pxi", line 1915, in lxml.etree._parseMemoryDocument File "src/lxml/parser.pxi", line 1803, in lxml.etree._parseDoc File "src/lxml/parser.pxi", line 1144, in lxml.etree._BaseParser._parseDoc File "src/lxml/parser.pxi", line 618, in lxml.etree._ParserContext._handleParseResultDoc File "src/lxml/parser.pxi", line 728, in lxml.etree._handleParseResult File "src/lxml/parser.pxi", line 657, in lxml.etree._raiseParseError File "<string>", line 202389 lxml.etree.XMLSyntaxError: xmlSAX2Characters: huge text node, line 202389, column 65
This is produced when handling an event with a very big description, I manage to fix this by activating 'huge_tree' in XMLParser in davclient.py. This option is not activated by default du to a security issue : https://lxml.de/api/lxml.etree.XMLParser-class.html
I'm not sure exactly what it is about but we may want to enable it by default for caldav or at least add an option for it in DAVClient ?

@tobixen
Copy link
Member

tobixen commented Mar 8, 2023

Sorry, I'm not going to "disable security restrictions" by default in the python caldav library, I suppose there is a reason why default is to enable those security restrictions in the lxml library. Passing it as an option when initiating the DAVClient object is acceptable.

aaujon pushed a commit to aaujon/caldav that referenced this issue Mar 8, 2023
@aaujon
Copy link
Author

aaujon commented Mar 8, 2023

I understand that, I rewrite the MR to allow to use an option when initiating DAVClient, I'm not sure about the way it's done, I don't really like having huge_tree variable in both DAVClient and DAVResponse class. Let me know if you have a better idea on how to handle it.

@tobixen
Copy link
Member

tobixen commented Mar 8, 2023

Perhaps it would be a better idea to have the reference to the DAVClient object stored in the DAVResponse class

@tobixen
Copy link
Member

tobixen commented Jul 19, 2023

There is an assert in the unit test that a huge string will cause an error to be raised unless huge_tree is passed ... but it seems like the huge XML is parsed without problems in some environments now, ref #320

I will remove that test but leave the left of the logic as it is.

@tobixen
Copy link
Member

tobixen commented Jul 19, 2023

... after all, the important thing is not that the caldav library fails on huge xml objects, the important thing is that they pass if the right flags are passed to the connection object :-)

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 a pull request may close this issue.

2 participants