From 4307c4e6b462941e78b221b7aef72702d077c117 Mon Sep 17 00:00:00 2001 From: "H. Shay" Date: Fri, 17 May 2024 15:20:28 -0700 Subject: [PATCH] fix url previewer --- synapse/rest/client/media.py | 7 ++++--- tests/media/test_media_storage.py | 8 -------- tests/rest/client/test_media.py | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/synapse/rest/client/media.py b/synapse/rest/client/media.py index e14438dcf66..172d2407838 100644 --- a/synapse/rest/client/media.py +++ b/synapse/rest/client/media.py @@ -195,9 +195,10 @@ async def on_GET( def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None: if hs.config.experimental.msc3916_authenticated_media_enabled: media_repo = hs.get_media_repository() - UnstablePreviewURLServlet(hs, media_repo, media_repo.media_storage).register( - http_server - ) + if hs.config.media.url_preview_enabled: + UnstablePreviewURLServlet( + hs, media_repo, media_repo.media_storage + ).register(http_server) UnstableMediaConfigResource(hs).register(http_server) UnstableThumbnailResource(hs, media_repo, media_repo.media_storage).register( http_server diff --git a/tests/media/test_media_storage.py b/tests/media/test_media_storage.py index 3bce406ec84..c8c79ab313d 100644 --- a/tests/media/test_media_storage.py +++ b/tests/media/test_media_storage.py @@ -290,14 +290,6 @@ def write_err(f: Failure) -> Failure: config = self.default_config() config["media_store_path"] = self.media_store_path config["max_image_pixels"] = 2000000 - config["url_preview_enabled"] = True - config["max_spider_size"] = 9999999 - config["url_preview_ip_range_blacklist"] = ( - "192.168.1.1", - "1.0.0.0/8", - "3fff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", - "2001:800::/21", - ) provider_config = { "module": "synapse.media.storage_provider.FileStorageProviderBackend", diff --git a/tests/rest/client/test_media.py b/tests/rest/client/test_media.py index fd914a4eb30..a20fe698eed 100644 --- a/tests/rest/client/test_media.py +++ b/tests/rest/client/test_media.py @@ -168,10 +168,10 @@ def test_remote_media_thumbnail_normally_unblocked(self) -> None: class UnstableURLPreviewTests(unittest.HomeserverTestCase): - servlets = [media.register_servlets] if not lxml: skip = "url preview feature requires lxml" + servlets = [media.register_servlets] hijack_auth = True user_id = "@test:user" end_content = (