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

VCardImage parsing failures #13

Closed
Jajcus opened this issue Jun 1, 2011 · 0 comments
Closed

VCardImage parsing failures #13

Jajcus opened this issue Jun 1, 2011 · 0 comments

Comments

@Jajcus
Copy link
Owner

Jajcus commented Jun 1, 2011

[source:trunk/pyxmpp/jabber/vcard.py##L394 line 394 of vcard.py] fails when there is no key {{{"value"}}} in the {{{rfc2425parameters}}} dict object. The current code below:
{{{
if rfc2425parameters.get("value").lower()=="uri":
}}}
when {{{"value"}}} does not exist in the dictionary, {{{get("value")}}} returns {{{None}}}, resulting in {{{None.lower()}}} which finally throws an exception:
{{{
AttributeError: 'NoneType' object has no attribute 'lower'
}}}
This is caused by the default return value from get, which itself defaults to {{{None}}}. My fix is to include a default value of empty string:

{{{
if rfc2425parameters.get("value", '').lower()=="uri":

}}}

I also had some trouble with not all of the attributes being initialized when parsing from !rfc2425 versions, my fix is to move the initialization with {{{None}}} out of the if statement on [source:trunk/pyxmpp/jabber/vcard.py##L370 line 370 of vcard.py].
{{{
if isinstance(value,libxml2.xmlNode):
self.uri,self.type,self.image=[None]_3
}}}
becomes
{{{
self.uri,self.type,self.image=[None]_3
if isinstance(value,libxml2.xmlNode):
}}}

Copy of the PyXMPP issue Jajcus/pyxmpp#13

@Jajcus Jajcus closed this as completed Jun 1, 2011
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

No branches or pull requests

1 participant