From d91b71ae4829a40e432a3dd2940a345d56fa496e Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Wed, 9 Feb 2022 15:53:18 +0100 Subject: [PATCH 1/2] escape uri on subdomain skylink requests --- docker/nginx/conf.d/server/server.skylink | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docker/nginx/conf.d/server/server.skylink b/docker/nginx/conf.d/server/server.skylink index 14c0870e..11ae48d7 100644 --- a/docker/nginx/conf.d/server/server.skylink +++ b/docker/nginx/conf.d/server/server.skylink @@ -6,7 +6,12 @@ include /etc/nginx/conf.d/include/init-optional-variables; location / { set_by_lua_block $skylink { return string.match(ngx.var.host, "%w+") } - set $path $uri; + set_by_lua_block $path { + -- strip ngx.var.request_uri from query params - this is basically the same as ngx.var.uri but + -- do not use ngx.var.uri because it will already be unescaped and we need to use escaped path + -- examples: escaped uri "/b%20r56+7" and unescaped uri: "/b r56 7" + return string.gsub(ngx.var.request_uri, "?.*", "") + } include /etc/nginx/conf.d/include/location-skylink; } From 1d006ef163e5837232f86d10bd6b28dcbf5f5059 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Wed, 9 Feb 2022 16:59:03 +0100 Subject: [PATCH 2/2] changelog entry --- .../bugs-fixed/escape-uri-on-subdomain-skylink-requests.md | 1 + docker/nginx/conf.d/server/server.skylink | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog/items/bugs-fixed/escape-uri-on-subdomain-skylink-requests.md diff --git a/changelog/items/bugs-fixed/escape-uri-on-subdomain-skylink-requests.md b/changelog/items/bugs-fixed/escape-uri-on-subdomain-skylink-requests.md new file mode 100644 index 00000000..3beabc7e --- /dev/null +++ b/changelog/items/bugs-fixed/escape-uri-on-subdomain-skylink-requests.md @@ -0,0 +1 @@ +- fixed a bug when accessing file from skylink via subdomain with a filename that had escaped characters diff --git a/docker/nginx/conf.d/server/server.skylink b/docker/nginx/conf.d/server/server.skylink index 11ae48d7..a8f659f1 100644 --- a/docker/nginx/conf.d/server/server.skylink +++ b/docker/nginx/conf.d/server/server.skylink @@ -9,7 +9,7 @@ location / { set_by_lua_block $path { -- strip ngx.var.request_uri from query params - this is basically the same as ngx.var.uri but -- do not use ngx.var.uri because it will already be unescaped and we need to use escaped path - -- examples: escaped uri "/b%20r56+7" and unescaped uri: "/b r56 7" + -- examples: escaped uri "/b%20r56+7" and unescaped uri "/b r56 7" return string.gsub(ngx.var.request_uri, "?.*", "") }