diff --git a/src/yaws_api.erl b/src/yaws_api.erl index 0df15df7a..a2f340e8f 100644 --- a/src/yaws_api.erl +++ b/src/yaws_api.erl @@ -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);