From 1d6664b1f46c7dae805ff5b3d7ea79265a58bb84 Mon Sep 17 00:00:00 2001 From: Phantasm Date: Mon, 1 Jun 2026 21:50:20 +0200 Subject: [PATCH] InstanceStaticPlug: Add more override and fallback tests --- .../web/plugs/instance_static_test.exs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/pleroma/web/plugs/instance_static_test.exs b/test/pleroma/web/plugs/instance_static_test.exs index b5a5a3334..1d67e8dc3 100644 --- a/test/pleroma/web/plugs/instance_static_test.exs +++ b/test/pleroma/web/plugs/instance_static_test.exs @@ -61,6 +61,28 @@ defmodule Pleroma.Web.Plugs.InstanceStaticTest do File.write!(@dir <> "/static/kaniini.html", "

rabbit hugs as a service

") index = get(build_conn(), "/static/kaniini.html") assert html_response(index, 200) == "

rabbit hugs as a service

" + + File.write!(@dir <> "/static/kaniini the bnuuy.html", "

rabbit hugs as a service

") + index = get(build_conn(), "/static/kaniini%20the%20bnuuy.html") + assert html_response(index, 200) == "

rabbit hugs as a service

" + end + + test "overrides /static/styles files with spaces in URL" do + Pleroma.Backports.mkdir_p!(@dir <> "/static/styles") + File.write(@dir <> "/static/styles/Redmond DX.iss", "overridden") + + index = get(build_conn(), "/static/styles/Redmond%20DX.iss") + assert index.status == 200 + assert index.resp_body == File.read!(@dir <> "/static/styles/Redmond DX.iss") + assert index.halted == true + end + + test "serves fallback /static/styles files with spaces in URL" do + index = get(build_conn(), "/static/styles/Redmond%20DX.iss") + + assert index.status == 200 + assert index.resp_body == File.read!("priv/static/static/styles/Redmond DX.iss") + assert index.halted == true end test "does not sanitize dangerous files in general, as there can be html and javascript files legitimately in this folder" do