Fix getting sender from a combination of legacy Diaspora encrypted payload and new entity names

For example `author`. This combination probably only existed in this library.
merge-requests/130/head
Jason Robinson 2017-06-08 23:37:59 +03:00
rodzic e28e3fd587
commit 78d344d6a8
3 zmienionych plików z 15 dodań i 2 usunięć

Wyświetl plik

@ -1,5 +1,10 @@
# Changelog
## [unreleased]
### Fixed
* Fix getting sender from a combination of legacy Diaspora encrypted payload and new entity names (for example `author`). This combination probably only existed in this library.
## [0.12.0] - 2017-05-22
### Backwards incompatible changes

Wyświetl plik

@ -118,7 +118,9 @@ class Protocol(BaseProtocol):
except AttributeError:
# Look at the message, try various elements
message = etree.fromstring(self.content)
element = message.find(".//sender_handle")
element = message.find(".//author")
if element is None:
element = message.find(".//sender_handle")
if element is None:
element = message.find(".//diaspora_handle")
if element is None:
@ -137,6 +139,7 @@ class Protocol(BaseProtocol):
else:
body = urlsafe_b64decode(body.encode("ascii"))
logger.debug("diaspora.protocol.get_message_content: %s", body)
return body
def _get_encrypted_body(self, body):

Wyświetl plik

@ -36,7 +36,12 @@ def retrieve_diaspora_webfinger(handle):
:arg handle: Remote handle to retrieve
:returns: ``XRD`` instance
"""
hostmeta = retrieve_diaspora_host_meta(handle.split("@")[1])
try:
host = handle.split("@")[1]
except AttributeError:
logger.warning("retrieve_diaspora_webfinger: invalid handle given: %s", handle)
return None
hostmeta = retrieve_diaspora_host_meta(host)
if not hostmeta:
return None
url = hostmeta.find_link(rels="lrdd").template.replace("{uri}", quote(handle))