diff options
author | Richard van der Hoff <github@rvanderhoff.org.uk> | 2017-03-14 23:40:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-14 23:40:35 +0000 |
commit | f2ed64eaaf4054268d64863e512ba90f2000ee0d (patch) | |
tree | b15cea665b7886791c325bbe9dd0849f0b68435d /synapse/rest/media/v1/download_resource.py | |
parent | Merge pull request #2002 from matrix-org/erikj/dont_sync_by_default (diff) | |
parent | kick jenkins (diff) | |
download | synapse-f2ed64eaaf4054268d64863e512ba90f2000ee0d.tar.xz |
Merge pull request #1992 from matrix-org/rav/fix_media_loop
Fix routing loop when fetching remote media
Diffstat (limited to 'synapse/rest/media/v1/download_resource.py')
-rw-r--r-- | synapse/rest/media/v1/download_resource.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/synapse/rest/media/v1/download_resource.py b/synapse/rest/media/v1/download_resource.py index dfb87ffd15..6788375e85 100644 --- a/synapse/rest/media/v1/download_resource.py +++ b/synapse/rest/media/v1/download_resource.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import synapse.http.servlet from ._base import parse_media_id, respond_with_file, respond_404 from twisted.web.resource import Resource @@ -81,6 +82,17 @@ class DownloadResource(Resource): @defer.inlineCallbacks def _respond_remote_file(self, request, server_name, media_id, name): + # don't forward requests for remote media if allow_remote is false + allow_remote = synapse.http.servlet.parse_boolean( + request, "allow_remote", default=True) + if not allow_remote: + logger.info( + "Rejecting request for remote media %s/%s due to allow_remote", + server_name, media_id, + ) + respond_404(request) + return + media_info = yield self.media_repo.get_remote_media(server_name, media_id) media_type = media_info["media_type"] |