diff options
author | Erlang/OTP <[email protected]> | 2011-11-11 11:14:54 +0100 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2011-11-11 11:14:54 +0100 |
commit | f02b4691e1d53a49b1dda9e716649cad4f060ecc (patch) | |
tree | 476e13929469a3061f82510a0b3d39b6bdb5aabc /lib/inets/src/http_lib/http_uri.erl | |
parent | 758e7b817293f7da71c5bdf2c2e2eb6f70e23687 (diff) | |
parent | d84a96ec6caed792972c1d5359ef193e608882cf (diff) | |
download | otp-f02b4691e1d53a49b1dda9e716649cad4f060ecc.tar.gz otp-f02b4691e1d53a49b1dda9e716649cad4f060ecc.tar.bz2 otp-f02b4691e1d53a49b1dda9e716649cad4f060ecc.zip |
Merge branch 'bmk/inets/inets572_integration' into maint-r14
* bmk/inets/inets572_integration:
Commas and more commas...
More merge cleanup.
Aftermerge cleanup.
[httpd] GET request with malformed header date caused server crash (non-fatal) with no reply to client. Will now result in a reply with status code 400. OTP-9674
Added versions 5.2, 5.1.3 and 5.1.2 again. OTP-9655
Uncommented ipv6 test cases. OTP-9655
Fixed HTML encode. First *try* to hex decode uri, and then do the actual html encode. OTP-9655
Skip catching hex decode failure. OTP-9655
Fixed hex-decoding. OTP-9655
Problems with proxy test cases. OTP-9655
Added release notes, appup and correct version. OTP-9655
The XSS prevention methods used was confused if the URL was encoded (hex-encoded). OTP-9655
Diffstat (limited to 'lib/inets/src/http_lib/http_uri.erl')
-rw-r--r-- | lib/inets/src/http_lib/http_uri.erl | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/lib/inets/src/http_lib/http_uri.erl b/lib/inets/src/http_lib/http_uri.erl index 44b9face0b..607475c359 100644 --- a/lib/inets/src/http_lib/http_uri.erl +++ b/lib/inets/src/http_lib/http_uri.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2006-2010. All Rights Reserved. +%% Copyright Ericsson AB 2006-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -20,7 +20,9 @@ -module(http_uri). --export([parse/1, encode/1, decode/1]). +-export([parse/1]). +-export([encode/1, decode/1]). + %%%========================================================================= %%% API @@ -42,20 +44,24 @@ encode(URI) -> Reserved = sets:from_list([$;, $:, $@, $&, $=, $+, $,, $/, $?, $#, $[, $], $<, $>, $\", ${, $}, $|, $\\, $', $^, $%, $ ]), - lists:append(lists:map(fun(Char) -> - uri_encode(Char, Reserved) - end, URI)). - -decode([$%,Hex1,Hex2|Rest]) -> - [hex2dec(Hex1)*16+hex2dec(Hex2)|decode(Rest)]; -decode([First|Rest]) -> - [First|decode(Rest)]; -decode([]) -> + %% lists:append(lists:map(fun(Char) -> uri_encode(Char, Reserved) end, URI)). + lists:append([uri_encode(Char, Reserved) || Char <- URI]). + +decode(String) -> + do_decode(String). + +do_decode([$%,Hex1,Hex2|Rest]) -> + [hex2dec(Hex1)*16+hex2dec(Hex2)|do_decode(Rest)]; +do_decode([First|Rest]) -> + [First|do_decode(Rest)]; +do_decode([]) -> []. + %%%======================================================================== %%% Internal functions %%%======================================================================== + parse_scheme(AbsURI) -> case split_uri(AbsURI, ":", {error, no_scheme}, 1, 1) of {error, no_scheme} -> |