You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That expands file.html to d:\file.html in Windows (adds a drive letter), that is later is concatenated with public dir, giving final path ...\public\d:\file.html.
If this line is replaced with expanded_path = request_path, problem is gone and file is shown, but this is (perhaps) unacceptable as a fix - if I understand correctly, this line is to avoid a way to escape from public dir.
I'm not sure how correct fix should work - expand a path from a public dir then check that result is inside public dir? Or maybe expand_path in stdlib should be fixed to do not add a drive letter?
The text was updated successfully, but these errors were encountered:
Description
StaticFileHandler doesn't work on Windows due to
expand_path
adding drive letter in Windows.Steps to Reproduce
Kemal.run(trap_signal: false)
due to A simple hello world kemal app run on windows failed. (but compilation on github action successful) #658 )public
dir with some filesExpected behavior: In Windows, as in Linux, browser should show a file.
Actual behavior: Browser shows error (status 302 with pretty misleading message in case of Firefox)
Reproduces how often: Always
Versions
Crystal 1.9.2, Kemal 1.4.0
Additional Information
The problem is in a line
kemal/src/kemal/static_file_handler.cr
Line 30 in c995a2a
That expands
file.html
tod:\file.html
in Windows (adds a drive letter), that is later is concatenated with public dir, giving final path...\public\d:\file.html
.If this line is replaced with
expanded_path = request_path
, problem is gone and file is shown, but this is (perhaps) unacceptable as a fix - if I understand correctly, this line is to avoid a way to escape from public dir.I'm not sure how correct fix should work - expand a path from a
public
dir then check that result is insidepublic
dir? Or maybeexpand_path
in stdlib should be fixed to do not add a drive letter?The text was updated successfully, but these errors were encountered: