Skip to content

Commit

Permalink
mod_spam_filters: gracefully handle missing location header
Browse files Browse the repository at this point in the history
  • Loading branch information
sstrigler committed Jan 9, 2025
1 parent e8ed1d0 commit 1f8d04f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mod_spam_filter/src/mod_spam_filter.erl
Original file line number Diff line number Diff line change
Expand Up @@ -440,14 +440,14 @@ do_resolve_redirects([URL | Rest], Acc) ->
httpc:request(get, {URL, [{"user-agent", "curl/8.7.1"}]},
[{autoredirect, false}, {timeout, ?HTTPC_TIMEOUT}], [])
of
{ok, {{_, Moved, _}, Headers, _Body}} when Moved >= 300, Moved < 400 ->
{ok, {{_, StatusCode, _}, Headers, _Body}} when StatusCode >= 300, StatusCode < 400 ->
Location = proplists:get_value("location", Headers),
case lists:member(Location, Acc) of
false ->
do_resolve_redirects([Location | Rest], [URL | Acc]);
case Location == undefined orelse lists:member(Location, Acc) of
true ->
do_resolve_redirects(Rest, [URL | Acc])
end;
do_resolve_redirects(Rest, [URL | Acc]);
false ->
do_resolve_redirects([Location | Rest], [URL | Acc])
end;
_Res ->
do_resolve_redirects(Rest, [URL | Acc])
end.
Expand Down

0 comments on commit 1f8d04f

Please sign in to comment.