]> granicus.if.org Git - ejabberd/commitdiff
* src/web/ejabberd_http.erl: Fixed URL decoding code (EJAB-450)
authorMickaël Rémond <mickael.remond@process-one.net>
Sun, 9 Dec 2007 10:45:53 +0000 (10:45 +0000)
committerMickaël Rémond <mickael.remond@process-one.net>
Sun, 9 Dec 2007 10:45:53 +0000 (10:45 +0000)
SVN Revision: 1057

ChangeLog
src/web/ejabberd_http.erl

index 6b8230136589a3d1da65685a8dd6bd5b21d17bee..8e6d84bafbeeec2362bab65a0b5289fa41a36349 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2007-12-09  Mickael Remond  <mremond@process-one.net>
 
+       * src/web/ejabberd_http.erl: Fixed URL decoding code (EJAB-450)
+
        * src/msg/fr.msg: Added missing space.
 
 2007-12-09  Badlop  <badlop@process-one.net>
index 503eaf106b4aea12b4b91a27bc2acc5c8802c02c..90d871d225e68582ffaffb9c171ef2ab41c056ea 100644 (file)
@@ -513,22 +513,16 @@ crypt(S) when is_binary(S) ->
 url_decode_q_split(Path) ->
     url_decode_q_split(Path, []).
 
-url_decode_q_split([$%, $C, $2, $%, Hi, Lo | Tail], Ack) ->
-    Hex = hex_to_integer([Hi, Lo]),
-    url_decode_q_split(Tail, [Hex|Ack]);
-url_decode_q_split([$%, $C, $3, $%, Hi, Lo | Tail], Ack) when Hi > $9 ->
-    Hex = hex_to_integer([Hi+4, Lo]),
-    url_decode_q_split(Tail, [Hex|Ack]);
-url_decode_q_split([$%, $C, $3, $%, Hi, Lo | Tail], Ack) when Hi < $A ->
-    Hex = hex_to_integer([Hi+4+7, Lo]),
-    url_decode_q_split(Tail, [Hex|Ack]);
 url_decode_q_split([$%, Hi, Lo | Tail], Ack) ->
     Hex = hex_to_integer([Hi, Lo]),
+    if Hex  == 0 -> exit(badurl);
+       true -> ok
+    end,
     url_decode_q_split(Tail, [Hex|Ack]);
 url_decode_q_split([$?|T], Ack) ->
     %% Don't decode the query string here, that is parsed separately.
     {path_norm_reverse(Ack), T};
-url_decode_q_split([H|T], Ack) ->
+url_decode_q_split([H|T], Ack) when H /= 0 -> 
     url_decode_q_split(T, [H|Ack]);
 url_decode_q_split([], Ack) ->
     {path_norm_reverse(Ack), []}.
@@ -542,15 +536,14 @@ start_dir(N, Path, "./"  ++ T ) -> start_dir(N    , Path, T);
 start_dir(N, Path, "../" ++ T ) -> start_dir(N + 1, Path, T);
 start_dir(N, Path,          T ) -> rest_dir (N    , Path, T).
 
-rest_dir (_N, Path, []         ) -> case Path of
+rest_dir (_N, Path, []         ) -> case Path of 
                                       [] -> "/";
                                       _  -> Path
                                   end;
 rest_dir (0, Path, [ $/ | T ] ) -> start_dir(0    , [ $/ | Path ], T);
 rest_dir (N, Path, [ $/ | T ] ) -> start_dir(N - 1,        Path  , T);
 rest_dir (0, Path, [  H | T ] ) -> rest_dir (0    , [  H | Path ], T);
-rest_dir (N, Path, [ _H | T ] ) -> rest_dir (N    ,        Path  , T).
-
+rest_dir (N, Path, [  _H | T ] ) -> rest_dir (N    ,        Path  , T).
 
 %% hex_to_integer