py-vobject / vobject

A full-featured Python package for parsing and creating iCalendar and vCard files
http://py-vobject.github.io/
29 stars 7 forks source link

Spurious backslash in GEO property lines #62

Closed l0b0 closed 1 month ago

l0b0 commented 1 month ago

The vCard 3.0 GEO type example shows a line like GEO:37.386013;-122.082932, but it seems the ;s are all prefixed by backslash when exporting from Radicale, becoming GEO:37.386013\;-122.082932. This causes validation to fail.

Reproduced with vobject 0.9.8.

Please see https://github.com/Kozea/Radicale/issues/1587 for full details.

da4089 commented 1 month ago

I have been able to reproduce the issue.

The immediate cause is that the GEO ContentLine is treated as type Text, and Text requires SEMI-COLON, COMMA, and BACKSLASH to be escaped with a leading BACKSLASH.

I think this is easily fixed by writing a GEO-specific behaviour class, but I haven't experimented with that just yet.

da4089 commented 1 month ago

Ok. I now have a GEO class implemented that appears to do the right thing.

My plan for 0.9.x is to add a simple GEO class that doesn't escape the SEMI-COLON when serializing. But that's all it will do -- any values will be accepted, as is the case today.

For 1.x, I'd like to extend that new GEO class to validate that the supplied value is a pair of floats separated by a SEMI-COLON, with the first in the range -90.0 to 90.0 and the second -180.0 to 180.0, check that there's no parameters supplied, and nothing else in the value.

I'm hesitant to do that in 0.9, given its wide deployment: making things more strict seems likely to break someone, somewhere, and I'd rather save that for the major version bump.