mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-09-07 04:21:54 +00:00
Fix /key/v2/server calls with URL-unsafe key IDs (#14490)
Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
This commit is contained in:
parent
78e23eea05
commit
e1b15f25f3
1
changelog.d/14490.misc
Normal file
1
changelog.d/14490.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix a bug introduced in Synapse 0.9 where it would fail to fetch server keys whose IDs contain a forward slash.
|
@ -857,7 +857,7 @@ class ServerKeyFetcher(BaseV2KeyFetcher):
|
|||||||
response = await self.client.get_json(
|
response = await self.client.get_json(
|
||||||
destination=server_name,
|
destination=server_name,
|
||||||
path="/_matrix/key/v2/server/"
|
path="/_matrix/key/v2/server/"
|
||||||
+ urllib.parse.quote(requested_key_id),
|
+ urllib.parse.quote(requested_key_id, safe=""),
|
||||||
ignore_backoff=True,
|
ignore_backoff=True,
|
||||||
# we only give the remote server 10s to respond. It should be an
|
# we only give the remote server 10s to respond. It should be an
|
||||||
# easy request to handle, so if it doesn't reply within 10s, it's
|
# easy request to handle, so if it doesn't reply within 10s, it's
|
||||||
|
@ -469,6 +469,18 @@ class ServerKeyFetcherTestCase(unittest.HomeserverTestCase):
|
|||||||
keys = self.get_success(fetcher.get_keys(SERVER_NAME, ["key1"], 0))
|
keys = self.get_success(fetcher.get_keys(SERVER_NAME, ["key1"], 0))
|
||||||
self.assertEqual(keys, {})
|
self.assertEqual(keys, {})
|
||||||
|
|
||||||
|
def test_keyid_containing_forward_slash(self) -> None:
|
||||||
|
"""We should url-encode any url unsafe chars in key ids.
|
||||||
|
|
||||||
|
Detects https://github.com/matrix-org/synapse/issues/14488.
|
||||||
|
"""
|
||||||
|
fetcher = ServerKeyFetcher(self.hs)
|
||||||
|
self.get_success(fetcher.get_keys("example.com", ["key/potato"], 0))
|
||||||
|
|
||||||
|
self.http_client.get_json.assert_called_once()
|
||||||
|
args, kwargs = self.http_client.get_json.call_args
|
||||||
|
self.assertEqual(kwargs["path"], "/_matrix/key/v2/server/key%2Fpotato")
|
||||||
|
|
||||||
|
|
||||||
class PerspectivesKeyFetcherTestCase(unittest.HomeserverTestCase):
|
class PerspectivesKeyFetcherTestCase(unittest.HomeserverTestCase):
|
||||||
def make_homeserver(self, reactor, clock):
|
def make_homeserver(self, reactor, clock):
|
||||||
|
Loading…
Reference in New Issue
Block a user