From 24f29192d80b793242ce0051d5f9c245d8b7c92f Mon Sep 17 00:00:00 2001 From: Alexander Kutsan Date: Sat, 27 Apr 2024 20:25:49 +0400 Subject: [PATCH] Directory Listing: Add UTF-8 Charset to the response Content type Within the directory listing handler, the absence of an explicit charset in the content type has led to issues, particularly with directories containing non-ASCII symbols, resulting in broken displays. Adding charset charset=UTF-8 to the Content-type header fixes this issue. --- src/kemal/static_file_handler.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kemal/static_file_handler.cr b/src/kemal/static_file_handler.cr index dbeca28..11a3057 100644 --- a/src/kemal/static_file_handler.cr +++ b/src/kemal/static_file_handler.cr @@ -57,7 +57,7 @@ module Kemal end send_file(context, file_path) elsif config.is_a?(Hash) && config.fetch("dir_listing", false) - context.response.content_type = "text/html" + context.response.content_type = "text/html;charset=UTF-8;" directory_listing(context.response, request_path, file_path) else call_next(context)