Skip to content

Commit

Permalink
Handle encoded and non-encoded filenames
Browse files Browse the repository at this point in the history
Yaws issue 378 was due to incorrect handling of percent-encoded
filenames. The fix for that in commit bc691ea led to the problem
described in commit 866f363, but that commit again broke 378. To
handle both issues, change yaws_api:url_decode_with_encoding/2 to
employ the unicode decoding approaches from both commits.
  • Loading branch information
vinoski committed Jun 23, 2019
1 parent 866f363 commit b703951
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/yaws_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -796,16 +796,17 @@ url_decode_with_encoding(Path, Encoding) ->
DecPath1 = case Encoding of
latin1 ->
DecPath;
undefined ->
case unicode:characters_to_list(list_to_binary(DecPath)) of
UTF8DecPath when is_list(UTF8DecPath) -> UTF8DecPath;
_ -> DecPath
end;
_ ->
case unicode:characters_to_list(DecPath, Encoding) of
try unicode:characters_to_list(list_to_binary(DecPath)) of
UTF8DecPath when is_list(UTF8DecPath) -> UTF8DecPath;
_ -> DecPath
end
catch
error:badarg ->
case unicode:characters_to_list(DecPath, Encoding) of
UTF8DecPath when is_list(UTF8DecPath) -> UTF8DecPath;
_ -> DecPath
end
end
end,
case QS of
[] -> lists:flatten(DecPath1);
Expand Down

0 comments on commit b703951

Please # to comment.