mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-06 10:55:52 +00:00
Fix semicolon bug
Fix #70 Also remove multiple parameters from vcard template. Android JB for example converts this: Email: lol@lol (work) Email: lol@lol (home) to this: EMAIL;TYPE=WORK:lol@lol which is exactly what icalendar (our parser) does too. ownCloud on the other hand converts this: EMAIL;TYPE=HOME,WORK:lol@lol to this: EMAIL;TYPE=HOME;TYPE=WORK:lol@lol So at this point it does not really matter anymore whether our behavior is RFC-conform or not.
This commit is contained in:
parent
f59c8d1fdf
commit
96d55c523c
2 changed files with 16 additions and 5 deletions
|
|
@ -31,11 +31,11 @@ VERSION:3.0
|
|||
FN:Cyrus Daboo
|
||||
N:Daboo;Cyrus
|
||||
ADR;TYPE=POSTAL:;2822 Email HQ;Suite 2821;RFCVille;PA;15213;USA
|
||||
EMAIL;TYPE=INTERNET;TYPE=PREF:cyrus@example.com
|
||||
EMAIL;TYPE=PREF:cyrus@example.com
|
||||
NICKNAME:me
|
||||
NOTE:Example VCard.
|
||||
ORG:Self Employed
|
||||
TEL;TYPE=WORK;TYPE=VOICE:412 605 0499
|
||||
TEL;TYPE=VOICE:412 605 0499
|
||||
TEL;TYPE=FAX:412 605 0705
|
||||
URL:http://www.example.com
|
||||
X-SOMETHING:{r}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,17 @@ import icalendar.parser
|
|||
|
||||
from . import text_type, itervalues
|
||||
|
||||
IGNORE_PROPS = frozenset((
|
||||
|
||||
def _process_properties(*s):
|
||||
rv = set()
|
||||
for key in s:
|
||||
rv.add(key + ':')
|
||||
rv.add(key + ';')
|
||||
|
||||
return frozenset(rv)
|
||||
|
||||
|
||||
IGNORE_PROPS = _process_properties(
|
||||
# PRODID is changed by radicale for some reason after upload
|
||||
'PRODID',
|
||||
# VERSION can get lost in singlefile storage
|
||||
|
|
@ -24,7 +34,7 @@ IGNORE_PROPS = frozenset((
|
|||
# REV is from the VCARD specification and is supposed to change when the
|
||||
# item does -- however, we can determine that ourselves
|
||||
'REV'
|
||||
))
|
||||
)
|
||||
|
||||
|
||||
def normalize_item(text, ignore_props=IGNORE_PROPS, use_icalendar=True):
|
||||
|
|
@ -38,7 +48,7 @@ def normalize_item(text, ignore_props=IGNORE_PROPS, use_icalendar=True):
|
|||
return u'\r\n'.join(line.strip()
|
||||
for line in lines
|
||||
if line.strip() and
|
||||
not any(line.startswith(p + ':')
|
||||
not any(line.startswith(p)
|
||||
for p in IGNORE_PROPS))
|
||||
|
||||
|
||||
|
|
@ -83,6 +93,7 @@ def to_unicode_lines(item):
|
|||
|
||||
for content_line in item.content_lines():
|
||||
if content_line:
|
||||
content_line = content_line.replace(u'\\;', u';')
|
||||
yield icalendar.parser.foldline(content_line)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue