Closed leoliu closed 5 years ago
There are other issues with that function. For example it converts URL to binary according to file:native_name_encoding()
which is only correct when serving files from the system. But request can also be handled by an appmod i.e. it has nothing to do with file path. It all accidentally works out because the emulator defaults to utf8
.
The call to file:native_name_encoding/0
is an attempt to guess the native encoding of the system. Yes, it's flawed, since the +pc
startup option to the erl
emulator can change things. Perhaps using io_lib:printable_list/1
to decide about the URL
argument would be better, but I'd never claim to be an expert in these matters.
As for supporting binary, sure, I'll try to add that over the next few days.
Please give this branch a try when you get a chance, feedback welcomed.
Seems to be working well. Thanks.
@vinoski I just discovered a bug from this commit. 404 is returned for any request path that has unicode chars in it. For example place a file 你好.txt
in a directory that is served by yaws
and try to view it.
The requested URL /%E4%BD%A0%E5%A5%BD.txt was not found on this server.
Could you open a new issue for that? It's easier to track that way. Thanks.
Could
yaws_api:url_encode/1
be made to support binary? I often get a crash like this: