http_uri:decode equivalent in uri_string module

Loïc Hoguin essen@REDACTED
Mon Mar 2 09:13:57 CET 2020


After using uri_string:normalize(URI, [return_map]) or equivalent, there 
are very few %HexHex left to decode. For example, the path will only 
have %2f left and it should be trivial to do the final decode after 
you've split the path into a path segment. It's a similar situation for 
the other fragments. The function string:replace/4 is probably enough 
for these cases.

In a related PR https://github.com/erlang/otp/pull/2492 we have 
discussed this and the result was to improve the documentation. I don't 
know if it's done yet.

If you still need a general decode function, Cowlib's cow_uri and cow_qs 
still have them. Other third party projects probably do as well.

Cheers,

On 02/03/2020 05:15, Shunichi Shinohara wrote:
> Hi List,
> 
> I'm now trying OTP-23.0-rc1 and find http_uri module's several functions are now
> marked deprecated. The decode fuction, which just decodes "%HexHex", is one of
> them and the compiler suggests to use uri_string module.
> https://github.com/erlang/otp/blob/OTP-23.0-rc1/lib/inets/src/http_lib/http_uri.erl#L68
> 
> Reading uri_string.erl but I could not find equivalent function in it...
> Similar one is decode function but it's module private, and it has
> utf8 validation.
> It's easy to implement it in my app, but it may be better that OTP has
> the altenative.
> 
> Thanks,
> Shino
> 

-- 
Loïc Hoguin
https://ninenines.eu


More information about the erlang-questions mailing list