From 6769f83da0f193052a30ff8933a014e9cf3b0cdf Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Mon, 31 May 2010 12:00:00 +0200 Subject: inets: Patch 1122 OTP-8609 [httpc] Made cookie handling more case insensitive. OTP-8610 [httpc|httpd] Some netscape cookie dates are given with a 2-digit year (e.g. 06 = 2006). OTP-8624 [httpd] Added support (again) for the documented debugging features. See the User's Guide Configuration chapter for more info. --- lib/inets/src/http_lib/http_util.erl | 106 ++++++++++++++++++++++++++++------- 1 file changed, 87 insertions(+), 19 deletions(-) (limited to 'lib/inets/src/http_lib') diff --git a/lib/inets/src/http_lib/http_util.erl b/lib/inets/src/http_lib/http_util.erl index ddb58c7116..4f1147176c 100644 --- a/lib/inets/src/http_lib/http_util.erl +++ b/lib/inets/src/http_lib/http_util.erl @@ -38,13 +38,79 @@ to_upper(Str) -> to_lower(Str) -> string:to_lower(Str). -convert_netscapecookie_date([_D,_A,_Y, $,, _SP, - D1,D2,_DA, - M,O,N,_DA, - Y1,Y2,Y3,Y4,_SP, - H1,H2,_Col, - M1,M2,_Col, +%% Example: Mon, 09-Dec-2002 13:46:00 GMT +convert_netscapecookie_date([_D,_A,_Y, $,, $ , + D1,D2, $-, + M,O,N, $-, + Y1,Y2,Y3,Y4, $ , + H1,H2, $:, + M1,M2, $:, + S1,S2|_Rest]) -> + Year = list_to_integer([Y1,Y2,Y3,Y4]), + Day = list_to_integer([D1,D2]), + Month = convert_month([M,O,N]), + Hour = list_to_integer([H1,H2]), + Min = list_to_integer([M1,M2]), + Sec = list_to_integer([S1,S2]), + {{Year,Month,Day},{Hour,Min,Sec}}; + +convert_netscapecookie_date([_D,_A,_Y, $,, $ , + D1,D2, $-, + M,O,N, $-, + Y3,Y4, $ , + H1,H2, $:, + M1,M2, $:, + S1,S2|_Rest]) -> + {CurrentYear, _, _} = date(), + [Y1,Y2|_] = integer_to_list(CurrentYear), + Year = list_to_integer([Y1,Y2,Y3,Y4]), + Day = list_to_integer([D1,D2]), + Month = convert_month([M,O,N]), + Hour = list_to_integer([H1,H2]), + Min = list_to_integer([M1,M2]), + Sec = list_to_integer([S1,S2]), + {{Year,Month,Day},{Hour,Min,Sec}}; + +convert_netscapecookie_date([_D,_A,_Y, $ , + D1,D2, $-, + M,O,N, $-, + Y1,Y2,Y3,Y4, $ , + H1,H2, $:, + M1,M2, $:, S1,S2|_Rest]) -> + Year = list_to_integer([Y1,Y2,Y3,Y4]), + Day = list_to_integer([D1,D2]), + Month = convert_month([M,O,N]), + Hour = list_to_integer([H1,H2]), + Min = list_to_integer([M1,M2]), + Sec = list_to_integer([S1,S2]), + {{Year,Month,Day},{Hour,Min,Sec}}; + +convert_netscapecookie_date([_D,_A,_Y, $ , + D1,D2, $-, + M,O,N, $-, + Y3,Y4, $ , + H1,H2, $:, + M1,M2, $:, + S1,S2|_Rest]) -> + {CurrentYear, _, _} = date(), + [Y1,Y2|_] = integer_to_list(CurrentYear), + Year = list_to_integer([Y1,Y2,Y3,Y4]), + Day = list_to_integer([D1,D2]), + Month = convert_month([M,O,N]), + Hour = list_to_integer([H1,H2]), + Min = list_to_integer([M1,M2]), + Sec = list_to_integer([S1,S2]), + {{Year,Month,Day},{Hour,Min,Sec}}; + +%% Sloppy... +convert_netscapecookie_date([_D,_A,_Y, $,, _SP, + D1,D2,_DA, + M,O,N,_DA, + Y1,Y2,Y3,Y4,_SP, + H1,H2,_Col, + M1,M2,_Col, + S1,S2|_Rest]) -> Year=list_to_integer([Y1,Y2,Y3,Y4]), Day=list_to_integer([D1,D2]), Month=convert_month([M,O,N]), @@ -54,12 +120,12 @@ convert_netscapecookie_date([_D,_A,_Y, $,, _SP, {{Year,Month,Day},{Hour,Min,Sec}}; convert_netscapecookie_date([_D,_A,_Y, _SP, - D1,D2,_DA, - M,O,N,_DA, - Y1,Y2,Y3,Y4,_SP, - H1,H2,_Col, - M1,M2,_Col, - S1,S2|_Rest]) -> + D1,D2,_DA, + M,O,N,_DA, + Y1,Y2,Y3,Y4,_SP, + H1,H2,_Col, + M1,M2,_Col, + S1,S2|_Rest]) -> Year=list_to_integer([Y1,Y2,Y3,Y4]), Day=list_to_integer([D1,D2]), Month=convert_month([M,O,N]), @@ -68,17 +134,17 @@ convert_netscapecookie_date([_D,_A,_Y, _SP, Sec=list_to_integer([S1,S2]), {{Year,Month,Day},{Hour,Min,Sec}}. -hexlist_to_integer([])-> +hexlist_to_integer([]) -> empty; %%When the string only contains one value its eaasy done. %% 0-9 -hexlist_to_integer([Size]) when Size >= 48 , Size =< 57 -> +hexlist_to_integer([Size]) when (Size >= 48) andalso (Size =< 57) -> Size - 48; %% A-F -hexlist_to_integer([Size]) when Size >= 65 , Size =< 70 -> +hexlist_to_integer([Size]) when (Size >= 65) andalso (Size =< 70) -> Size - 55; %% a-f -hexlist_to_integer([Size]) when Size >= 97 , Size =< 102 -> +hexlist_to_integer([Size]) when (Size >= 97) andalso (Size =< 102) -> Size - 87; hexlist_to_integer([_Size]) -> not_a_num; @@ -141,7 +207,7 @@ hexlist_to_integer2([HexVal | HexString], Pos, Sum) hexlist_to_integer2(_AfterHexString, _Pos, Sum)-> Sum. -integer_to_hexlist(Num, Pot, Res) when Pot<0 -> +integer_to_hexlist(Num, Pot, Res) when Pot < 0 -> convert_to_ascii([Num | Res]); integer_to_hexlist(Num,Pot,Res) -> @@ -163,7 +229,9 @@ convert_to_ascii(RevesedNum) -> convert_to_ascii([], Num)-> Num; -convert_to_ascii([Num | Reversed], Number) when Num > -1, Num < 10 -> +convert_to_ascii([Num | Reversed], Number) + when (Num > -1) andalso (Num < 10) -> convert_to_ascii(Reversed, [Num + 48 | Number]); -convert_to_ascii([Num | Reversed], Number) when Num > 9, Num < 16 -> +convert_to_ascii([Num | Reversed], Number) + when (Num > 9) andalso (Num < 16) -> convert_to_ascii(Reversed, [Num + 55 | Number]). -- cgit v1.2.3