logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/
commit: 0935823be98822d06a35c454bf58ab996e6f700b
parent bfe8372ad2de4d827eac89458f93620be5b05542
Author: Phantasm <phantasm@centrum.cz>
Date:   Mon, 20 Oct 2025 23:30:38 +0200

Add test for mangling incorrect URL in MediaProxy link generation

Diffstat:

Mtest/pleroma/web/media_proxy_test.exs19++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/test/pleroma/web/media_proxy_test.exs b/test/pleroma/web/media_proxy_test.exs @@ -173,11 +173,28 @@ defmodule Pleroma.Web.MediaProxyTest do # Improperly encoded URLs should not happen even when input was wrong. test "does not preserve unicode characters" do url = "https://ko.wikipedia.org/wiki/위키백과:대문" - encoded_url = "https://ko.wikipedia.org/wiki/%EC%9C%84%ED%82%A4%EB%B0%B1%EA%B3%BC:%EB%8C%80%EB%AC%B8" + + encoded_url = + "https://ko.wikipedia.org/wiki/%EC%9C%84%ED%82%A4%EB%B0%B1%EA%B3%BC:%EB%8C%80%EB%AC%B8" encoded = MediaProxy.url(url) assert decode_result(encoded) == encoded_url end + + # If we preserve wrongly encoded URLs in MediaProxy, it will get fixed + # when we GET these URLs and will result in 424 when MediaProxy previews are enabled. + test "does not preserve incorrect URLs when making MediaProxy link" do + incorrect_original_url = "https://example.com/media/cofe%20%28with%20milk%29.png" + corrected_original_url = "https://example.com/media/cofe%20(with%20milk).png" + + unpreserved_encoded_original_url = + "http://localhost:4001/proxy/Sv6tt6xjA72_i4d8gXbuMAOXQSs/aHR0cHM6Ly9leGFtcGxlLmNvbS9tZWRpYS9jb2ZlJTIwKHdpdGglMjBtaWxrKS5wbmc/cofe%20(with%20milk).png" + + encoded = MediaProxy.url(incorrect_original_url) + + assert encoded == unpreserved_encoded_original_url + assert decode_result(encoded) == corrected_original_url + end end describe "when disabled" do