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

Support DQUOTE character in property parameter values #219

Open
WhyNotHugo opened this Issue Mar 16, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@WhyNotHugo
Copy link

WhyNotHugo commented Mar 16, 2017

Parsing this [apparently] valid file fails/crashes:

BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//Apple Inc.//iOS 10.2.1//EN
VERSION:2.0
BEGIN:VTODO
COMPLETED:20170312T122019Z
CREATED:20170312T051318Z
DTSTAMP:20170312T122023Z
LAST-MODIFIED:20170312T122021Z
PERCENT-COMPLETE:100
PRIORITY:1
SEQUENCE:0
STATUS:COMPLETED
SUMMARY:Cosas en el freezer
UID:5ACD2904-D0CE-4097-BC75-C1EB95C0BB22
X-APPLE-SORT-ORDER:510988398
BEGIN:VALARM
ACKNOWLEDGED:20170312T122015Z
ACTION:DISPLAY
DESCRIPTION:Reminder
TRIGGER;VALUE=DATE-TIME:19760401T005545Z
UID:E13840A6-C30C-4BF0-A3E1-73EF27E34BD9
X-APPLE-PROXIMITY:ARRIVE
X-APPLE-STRUCTURED-LOCATION;VALUE=URI;X-ADDRESS=Ayacucho 983\\nPlata Baja 
 \"A\"\\nC1111AAC CABA\\nArgentina\\nArgentina;X-APPLE-ABUID="ab://Home";
 X-APPLE-RADIUS=0;X-APPLE-REFERENCEFRAME=1;X-TITLE=Home:geo:
 -34.597613,-58.395858
X-WR-ALARMUID:E13840A6-C30C-4BF0-A3E1-73EF27E34BD9
END:VALARM
END:VTODO
END:VCALENDAR

Traceback:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/icalendar/parser.py", line 241, in from_ical
    validate_param_value(v, quoted=False)
  File "/usr/lib/python3.6/site-packages/icalendar/parser.py", line 132, in validate_param_value
    raise ValueError(value)
ValueError: Ayacucho 983%5CnPlata Baja \"A\"%5CnC1111AAC CABA%5CnArgentina%5CnArgentina

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/icalendar/parser.py", line 336, in parts
    strict=self.strict)
  File "/usr/lib/python3.6/site-packages/icalendar/parser.py", line 255, in from_ical
    % (param, exc))
ValueError: 'X-ADDRESS=Ayacucho 983%5CnPlata Baja \\"A\\"%5CnC1111AAC CABA%5CnArgentina%5CnArgentina' is not a valid parameter string: Ayacucho 983%5CnPlata Baja \"A\"%5CnC1111AAC
 CABA%5CnArgentina%5CnArgentina

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/todoman/model.py", line 799, in update_cache
    todo = FileTodo.from_file(entry_path)
  File "/usr/lib/python3.6/site-packages/todoman/model.py", line 309, in from_file
    cal = icalendar.Calendar.from_ical(cal)
  File "/usr/lib/python3.6/site-packages/icalendar/cal.py", line 330, in from_ical
    name, params, vals = line.parts()
  File "/usr/lib/python3.6/site-packages/icalendar/parser.py", line 346, in parts
    % (self, exc)
ValueError: Content line could not be parsed into parts: 'X-APPLE-STRUCTURED-LOCATION;VALUE=URI;X-ADDRESS=Ayacucho 983\\nPlata Baja \"A\"\\nC1111AAC CABA\\nArgentina\\nArgentina;X-APPLE-ABUID="ab://Home";X-APPLE-RADIUS=0;X-APPLE-REFERENCEFRAME=1;X-TITLE=Home:geo:-34.597613,-58.395858': 'X-ADDRESS=Ayacucho 983%5CnPlata Baja \\"A\\"%5CnC1111AAC CABA%5CnArgen
tina%5CnArgentina' is not a valid parameter string: Ayacucho 983%5CnPlata Baja \"A\"%5CnC1111AAC CABA%5CnArgentina%5CnArgentina
@WhyNotHugo

This comment has been minimized.

Copy link
Author

WhyNotHugo commented Mar 16, 2017

This may be related to #197, but I don't think this is binary data (is it?).

@geier

This comment has been minimized.

Copy link
Contributor

geier commented Mar 16, 2017

Try #207 and see if it's gone.

@WhyNotHugo

This comment has been minimized.

Copy link
Author

WhyNotHugo commented Mar 16, 2017

Nope, exact same error with that branch. :(

@geier

This comment has been minimized.

Copy link
Contributor

geier commented Mar 16, 2017

The problem here are the quoted " around the A, by my reading of the RFC, Ayacucho 983\\nPlata Baja \"A\"\\nC1111AAC CABA\\nArgentina\\nArgentina is a property parameter and as the RFC states Property parameter values MUST NOT contain the DQUOTE character, this is not a valid icalendar file. If you can reproduce this, I you might want to file a bug with apple.

@WhyNotHugo

This comment has been minimized.

Copy link
Author

WhyNotHugo commented Mar 17, 2017

Ugh, yes, it's trivial to reproduce. I'll open up an issue there.

In the meantime, I wonder if we can skip unknown lines and parse the rest. At least then lines start with X-.

There'd have to be some way to inform of the mis-parse to the end-user though. Maybe a flag when parsing to actually enable this behaviour?

@geier geier changed the title Can't parse iOS location Support DQUOTE character in property parameter values Apr 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.