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 07df368
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions mod_spam_filter/src/mod_spam_filter.erl
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,17 @@ do_resolve_redirects([URL | Rest], Acc) ->
[{autoredirect, false}, {timeout, ?HTTPC_TIMEOUT}], [])
of
{ok, {{_, Moved, _}, Headers, _Body}} when Moved >= 300, Moved < 400 ->
Location = proplists:get_value("location", Headers),
case lists:member(Location, Acc) of
false ->
do_resolve_redirects([Location | Rest], [URL | Acc]);
true ->
do_resolve_redirects(Rest, [URL | Acc])
end;
case proplists:get_value("location", Headers) of
undefined ->
do_resolve_redirects(Rest, Acc);
Location ->
case lists:member(Location, Acc) of
false ->
do_resolve_redirects([Location | Rest], [URL | Acc]);
true ->
do_resolve_redirects(Rest, [URL | Acc])
end
end;
_Res ->
do_resolve_redirects(Rest, [URL | Acc])
end.
Expand Down

0 comments on commit 07df368

Please sign in to comment.