Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

VCard does not escape semicolons per RFC 2426 #21

Closed
Jajcus opened this issue May 3, 2011 · 2 comments
Closed

VCard does not escape semicolons per RFC 2426 #21

Jajcus opened this issue May 3, 2011 · 2 comments

Comments

@Jajcus
Copy link
Owner

Jajcus commented May 3, 2011

{{{

from pyxmpp.jabber.vcard import VCard, VCardName
v = VCard('')
n = VCardName('N', '')
n.given = 'Christopher; a semi-colon and a sentence, too.'
v.content['N'] = n
v.as_xml().serialize()
'\nChristopher; a semi-colon and a sentence, too.\n'
xml = [c for c in v.as_xml().children][0] #list comprehension to compensate for \nChristopher; a semi-colon and a sentence, too.Christopher; a semi-colon and a sentence, too.\n'
v.rfc2426()
'begin:VCARD\r\nversion:3.0\r\nn:;Christopher; a semi-colon and a sentence, too.;;;\r\nend:VCARD\r\n'
v3 = VCard(v.rfc2426())
Traceback (most recent call last):
File "", line 1, in
File "C:\workspace\lib\pyxmpp\jabber\vcard.py", line 1363, in init
self.n = None
File "C:\workspace\lib\pyxmpp\jabber\vcard.py", line 1477, in from_rfc2426
continue
File "C:\workspace\lib\pyxmpp\jabber\vcard.py", line 1508, in _process_rfc2425_record
if params:
File "C:\workspace\lib\pyxmpp\jabber\vcard.py", line 303, in __init

n=n.next
ValueError: too many values to unpack
}}}

since the semicolons are not backslash escaped, nor unescaped, string values with ';' in them cannot be handled properly.

a regex which can be used to properly split strings with escaped semicolons using a negative lookbehind assertion:
{{{non_quoted_semicolon_re=re.compile(r'(?<!);')}}}

I'll append patches and such as I finalize my fixes.

@Jajcus
Copy link
Owner Author

Jajcus commented May 3, 2011

--jajcus

@Jajcus
Copy link
Owner Author

Jajcus commented May 3, 2011

(In [711]) - properly escape semicolons in structured name fields (patch by Stelminator
plus a unit test). closes #21

--jajcus

@Jajcus Jajcus closed this as completed May 3, 2011
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant