From 07df36898e336ee6473b789d3fc78a7b95194b34 Mon Sep 17 00:00:00 2001 From: Stefan Strigler Date: Thu, 9 Jan 2025 08:22:52 +0100 Subject: [PATCH] mod_spam_filters: gracefully handle missing location header --- mod_spam_filter/src/mod_spam_filter.erl | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mod_spam_filter/src/mod_spam_filter.erl b/mod_spam_filter/src/mod_spam_filter.erl index 5e9ad82a..7c8af31a 100644 --- a/mod_spam_filter/src/mod_spam_filter.erl +++ b/mod_spam_filter/src/mod_spam_filter.erl @@ -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.