From: Badlop Date: Fri, 6 Oct 2017 11:15:47 +0000 (+0200) Subject: More fix in mod_http_fileserver to log URLs with/out query elements (#2021) X-Git-Tag: 17.11~137 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4bd5846d409f183e16301ee34f113ffb9f82967f;p=ejabberd More fix in mod_http_fileserver to log URLs with/out query elements (#2021) --- diff --git a/src/mod_http_fileserver.erl b/src/mod_http_fileserver.erl index 73423d6a7..f34936724 100644 --- a/src/mod_http_fileserver.erl +++ b/src/mod_http_fileserver.erl @@ -436,7 +436,7 @@ add_to_log(File, FileSize, Code, Request) -> IP = ip_to_string(element(1, Request#request.ip)), Path = join(Request#request.path, "/"), Query = case stringify_query(Request#request.q) of - [] -> + <<"">> -> ""; String -> [$? | String] @@ -456,11 +456,13 @@ add_to_log(File, FileSize, Code, Request) -> FileSize, Referer, UserAgent]). stringify_query(Q) -> - join( - lists:map(fun(E) -> - lists:concat([binary_to_list(element(1, E)), "=", binary_to_list(element(2, E))]) - end, Q), - "&"). + stringify_query(Q, []). +stringify_query([], Res) -> + join(lists:reverse(Res), "&"); +stringify_query([{nokey, _B} | Q], Res) -> + stringify_query(Q, Res); +stringify_query([{A, B} | Q], Res) -> + stringify_query(Q, [join([A,B], "=") | Res]). find_header(Header, Headers, Default) -> case lists:keysearch(Header, 1, Headers) of