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.
This commit is contained in:
Alexander Kutsan 2024-04-27 20:25:49 +04:00 committed by GitHub
parent 52ab623c50
commit 24f29192d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -57,7 +57,7 @@ module Kemal
end end
send_file(context, file_path) send_file(context, file_path)
elsif config.is_a?(Hash) && config.fetch("dir_listing", false) 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) directory_listing(context.response, request_path, file_path)
else else
call_next(context) call_next(context)