Skip to content

Commit

Permalink
Directory Listing: Add UTF-8 Charset to the response Content type
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alexkutsan committed Apr 27, 2024
1 parent 52ab623 commit 24f2919
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/kemal/static_file_handler.cr
Expand Up @@ -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)
Expand Down

0 comments on commit 24f2919

Please sign in to comment.