mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Fix crash in mod_http_fileserver when logging URL with query elements (#2021)
This commit is contained in:
parent
668d45cbc7
commit
280aa2f1b0
@ -424,8 +424,7 @@ add_to_log(File, FileSize, Code, Request) ->
|
||||
{{Year, Month, Day}, {Hour, Minute, Second}} = calendar:local_time(),
|
||||
IP = ip_to_string(element(1, Request#request.ip)),
|
||||
Path = join(Request#request.path, "/"),
|
||||
Query = case join(lists:map(fun(E) -> lists:concat([element(1, E), "=", binary_to_list(element(2, E))]) end,
|
||||
Request#request.q), "&") of
|
||||
Query = case stringify_query(Request#request.q) of
|
||||
[] ->
|
||||
"";
|
||||
String ->
|
||||
@ -445,6 +444,13 @@ add_to_log(File, FileSize, Code, Request) ->
|
||||
[IP, Day, Month, Year, Hour, Minute, Second, Request#request.method, Path, Query, Code,
|
||||
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),
|
||||
"&").
|
||||
|
||||
find_header(Header, Headers, Default) ->
|
||||
case lists:keysearch(Header, 1, Headers) of
|
||||
{value, {_, Value}} -> Value;
|
||||
|
Loading…
Reference in New Issue
Block a user