diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2010-04-16 12:00:36 +0100 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2010-04-18 10:16:51 +0100 |
commit | 5f9e7e0da5a89b80190087022a633eca7f7f2d8e (patch) | |
tree | 55e7a9301f723d1c562d9970bbb09eeab59e46d4 | |
parent | 5c8a90290f639ef2f3942ddcbb3626da4ae5f3b8 (diff) |
p2p: work around invalid SHA1D attributes appearing in msn objects
Fixes fd.o#27672
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | papyon/p2p.py | 30 |
2 files changed, 26 insertions, 5 deletions
@@ -7,6 +7,7 @@ Fixes: * Signal an error in IOChannel if resolving fails. (fd.o#27554) * Don't choke on trailing semicolons in message headers. (fd.o#27556) * Allow receiving gzip-encoded soap responses (fd.o#27673) + * Work around invalid SHA1D attributes appearing in MSN objects (fd.o#27672) papyon-0.4.6 (2010-04-08) ========================= diff --git a/papyon/p2p.py b/papyon/p2p.py index 1eff3bf..9058ec8 100644 --- a/papyon/p2p.py +++ b/papyon/p2p.py @@ -65,6 +65,30 @@ class MSNObjectType(object): LOCATION = 14 "Location" +def __decode_shad(shad, warning=True): + try: + shad = base64.b64decode(shad) + except TypeError: + # See fd.o#27672 for details on this workaround. + if ' ' in shad: + parts = shad.split(' ') + + # Try the first part. + shad = __decode_shad(parts[0], False) + + # Try the second part. + if shad is None: + shad = __decode_shad(parts[1], False) + + else: + # Only display this warning if we're not in a nested call otherwise the + # warning will be confusing. + if warning: + logger.warning("Invalid SHA1D in MSNObject: %s" % shad) + shad = None + + return shad + class MSNObject(object): "Represents an MSNObject." def __init__(self, creator, size, typ, location, friendly, @@ -156,11 +180,7 @@ class MSNObject(object): friendly = base64.b64decode(xml.unescape(element["Friendly"])) shad = element.get("SHA1D", None) if shad is not None: - try: - shad = base64.b64decode(shad) - except TypeError: - logger.warning("Invalid SHA1D in MSNObject: %s" % shad) - shad = None + shad = __decode_shad(shad) shac = element.get("SHA1C", None) if shac is not None: try: |