diff options
author | Christopher Lenz <cmlenz@apache.org> | 2008-05-23 19:27:52 +0000 |
---|---|---|
committer | Christopher Lenz <cmlenz@apache.org> | 2008-05-23 19:27:52 +0000 |
commit | 59a89fd650f4c419c5b2a6ea50ad6b1610fa8a10 (patch) | |
tree | b9e3a5c07a185ace9930d305b205c50117652829 /src | |
parent | b5c7b8bcfff3e361507b8ddb64edc94f90c13514 (diff) |
Patch MochiWeb for compatibility with R11B. This patch has been rejected upstream, but it's simple enough to just apply here.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@659636 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/mochiweb/mochifmt.erl | 2 | ||||
-rw-r--r-- | src/mochiweb/mochiweb_headers.erl | 2 | ||||
-rw-r--r-- | src/mochiweb/mochiweb_html.erl | 4 | ||||
-rw-r--r-- | src/mochiweb/mochiweb_multipart.erl | 2 | ||||
-rw-r--r-- | src/mochiweb/mochiweb_util.erl | 21 |
5 files changed, 23 insertions, 8 deletions
diff --git a/src/mochiweb/mochifmt.erl b/src/mochiweb/mochifmt.erl index da0a133a..696559d2 100644 --- a/src/mochiweb/mochifmt.erl +++ b/src/mochiweb/mochifmt.erl @@ -297,7 +297,7 @@ convert2(Arg, #conversion{ctype=oct}) -> convert2(Arg, #conversion{ctype=upper_hex}) -> erlang:integer_to_list(Arg, 16); convert2(Arg, #conversion{ctype=hex}) -> - string:to_lower(erlang:integer_to_list(Arg, 16)); + mochiweb_util:to_lower(erlang:integer_to_list(Arg, 16)); convert2(Arg, #conversion{ctype=char}) when Arg < 16#80 -> [Arg]; convert2(Arg, #conversion{ctype=char}) -> diff --git a/src/mochiweb/mochiweb_headers.erl b/src/mochiweb/mochiweb_headers.erl index df67c7d0..371df9f5 100644 --- a/src/mochiweb/mochiweb_headers.erl +++ b/src/mochiweb/mochiweb_headers.erl @@ -160,7 +160,7 @@ merge(_, V1, V0) -> V0 ++ ", " ++ V1. normalize(K) when is_list(K) -> - string:to_lower(K); + mochiweb_util:to_lower(K); normalize(K) when is_atom(K) -> normalize(atom_to_list(K)); normalize(K) when is_binary(K) -> diff --git a/src/mochiweb/mochiweb_html.erl b/src/mochiweb/mochiweb_html.erl index 0ac4826e..39ce51e6 100644 --- a/src/mochiweb/mochiweb_html.erl +++ b/src/mochiweb/mochiweb_html.erl @@ -328,7 +328,7 @@ tokens(B, S=#decoder{offset=O}, Acc) -> end. parse_flag({start_tag, B, _, false}) -> - case string:to_lower(binary_to_list(B)) of + case mochiweb_util:to_lower(binary_to_list(B)) of "script" -> script; "textarea" -> @@ -521,7 +521,7 @@ norm({Tag, Attrs}) -> norm(Tag) when is_binary(Tag) -> Tag; norm(Tag) -> - list_to_binary(string:to_lower(Tag)). + list_to_binary(mochiweb_util:to_lower(Tag)). test_destack() -> {<<"a">>, [], []} = diff --git a/src/mochiweb/mochiweb_multipart.erl b/src/mochiweb/mochiweb_multipart.erl index 9eb4badd..7d42be52 100644 --- a/src/mochiweb/mochiweb_multipart.erl +++ b/src/mochiweb/mochiweb_multipart.erl @@ -103,7 +103,7 @@ parse_headers(Binary, Acc) -> split_header(Line) -> {Name, [$: | Value]} = lists:splitwith(fun (C) -> C =/= $: end, binary_to_list(Line)), - {string:to_lower(string:strip(Name)), + {mochiweb_util:to_lower(string:strip(Name)), mochiweb_util:parse_header(Value)}. read_chunk(Req, Length) when Length > 0 -> diff --git a/src/mochiweb/mochiweb_util.erl b/src/mochiweb/mochiweb_util.erl index 7b66877d..e7026194 100644 --- a/src/mochiweb/mochiweb_util.erl +++ b/src/mochiweb/mochiweb_util.erl @@ -11,6 +11,7 @@ -export([guess_mime/1, parse_header/1]). -export([shell_quote/1, cmd/1, cmd_string/1, cmd_port/2]). -export([record_to_proplist/2, record_to_proplist/3]). +-export([to_lower/1]). -export([test/0]). -define(PERCENT, 37). % $\% @@ -170,7 +171,7 @@ urlsplit_scheme(Url) -> urlsplit_scheme([], Acc) -> {"", lists:reverse(Acc)}; urlsplit_scheme(":" ++ Rest, Acc) -> - {string:to_lower(lists:reverse(Acc)), Rest}; + {to_lower(lists:reverse(Acc)), Rest}; urlsplit_scheme([C | Rest], Acc) -> urlsplit_scheme(Rest, [C | Acc]). @@ -322,11 +323,11 @@ parse_header(String) -> %% Skip anything with no value Acc; {Name, [$\= | Value]} -> - [{string:to_lower(string:strip(Name)), + [{to_lower(string:strip(Name)), unquote_header(string:strip(Value))} | Acc] end end, - {string:to_lower(Type), + {to_lower(Type), lists:foldr(F, [], Parts)}. unquote_header("\"" ++ Rest) -> @@ -369,6 +370,20 @@ shell_quote([C | Rest], Acc) when C =:= $\" orelse C =:= $\` orelse shell_quote([C | Rest], Acc) -> shell_quote(Rest, [C | Acc]). +to_lower_char(C) when is_integer(C), C >= $A, C =< $Z -> + C + 32; +to_lower_char(C) when is_integer(C), C >= 16#C1, C =< 16#D6 -> + C + 32; +to_lower_char(C) when is_integer(C), C >= 16#D8, C =< 16#DE -> + C + 32; +to_lower_char(C) -> + C. + +to_lower(S) when is_list(S) -> + [to_lower_char(C) || C <- S]; +to_lower(C) when is_integer(C) -> + to_lower_char(C). + test() -> test_join(), test_quote_plus(), |