From e15145d9b78860b0be034248fd4736fb9fea52f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szikszai=20Guszt=C3=A1v?= Date: Thu, 28 Nov 2024 05:48:31 +0100 Subject: [PATCH] URI decode the request path. (#719) --- src/reactor.cr | 7 +++++-- src/test_runner.cr | 11 ++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/reactor.cr b/src/reactor.cr index e28244c5..541cda06 100644 --- a/src/reactor.cr +++ b/src/reactor.cr @@ -45,11 +45,14 @@ module Mint HTTP::CompressHandler.new, websocket_handler, ]) do |context| + path = + URI.decode(context.request.path) + # Handle the request depending on the result. content_type, content = - if file = @files[context.request.path]? + if file = @files[path]? { - MIME.from_filename?(context.request.path).to_s || "text/plain", + MIME.from_filename?(path).to_s || "text/plain", file.call, } else diff --git a/src/test_runner.cr b/src/test_runner.cr index c4517fc2..c2ba9d7e 100644 --- a/src/test_runner.cr +++ b/src/test_runner.cr @@ -97,14 +97,15 @@ module Mint end @server = - HTTP::Server.new([ - websocket_handler, - ]) do |context| + HTTP::Server.new([websocket_handler]) do |context| + path = + URI.decode(context.request.path) + # Handle the request depending on the result. content_type, content = - if file = @files[context.request.path]? + if file = @files[path]? { - MIME.from_filename?(context.request.path).to_s || "text/plain", + MIME.from_filename?(path).to_s || "text/plain", file.call, } else