summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2022-03-18 16:11:07 +0100
committerMaxime “pep” Buquet <pep@bouah.net>2022-03-19 10:31:34 +0100
commit7222ade0dd252380fb158bb9b1ca1fefec3899a5 (patch)
tree4b9928e15715badc2e942d0ed7b390440c349b9b
parent14a6c7801d8ecaabe69a1e28a26fb0755b5ee9dd (diff)
downloadslixmpp-7222ade0dd252380fb158bb9b1ca1fefec3899a5.tar.gz
slixmpp-7222ade0dd252380fb158bb9b1ca1fefec3899a5.tar.bz2
slixmpp-7222ade0dd252380fb158bb9b1ca1fefec3899a5.tar.xz
slixmpp-7222ade0dd252380fb158bb9b1ca1fefec3899a5.zip
xep_0454: Ensure format_url returns a str
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
-rw-r--r--slixmpp/plugins/xep_0454/__init__.py2
-rw-r--r--tests/test_xep_0454.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/slixmpp/plugins/xep_0454/__init__.py b/slixmpp/plugins/xep_0454/__init__.py
index 09d41221..34db0c79 100644
--- a/slixmpp/plugins/xep_0454/__init__.py
+++ b/slixmpp/plugins/xep_0454/__init__.py
@@ -117,7 +117,7 @@ class XEP_0454(BasePlugin):
"""Helper to format a HTTPS URL to an AESGCM URI"""
if not url.startswith('https://') or url.find('#') != -1:
raise InvalidURL
- url = 'aesgcm://' + url.removeprefix('https://') + '#' + fragment
+ return 'aesgcm://' + url.removeprefix('https://') + '#' + fragment
async def upload_file(
self,
diff --git a/tests/test_xep_0454.py b/tests/test_xep_0454.py
index 3d0860a9..8d43c7e3 100644
--- a/tests/test_xep_0454.py
+++ b/tests/test_xep_0454.py
@@ -32,4 +32,10 @@ class TestMediaSharing(SlixTest):
self.assertEqual(plain, result)
+ def testFormatURL(self):
+ url = 'https://foo.bar'
+ fragment = 'a' * 88
+ result = XEP_0454.format_url(url, fragment)
+ self.assertEqual('aesgcm://foo.bar#' + 'a' * 88, result)
+
suite = unittest.TestLoader().loadTestsFromTestCase(TestMediaSharing)