aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2025-05-29 00:44:16 +0100
committerGravatar Joe Banks <[email protected]>2025-05-29 00:44:16 +0100
commit64209c74d51c6a4efda77feac0152c7209d0f836 (patch)
treeeee8ca1da0e2e82489c4978951f9f4ca055e6774
parentParser should not fail for unrecognised tags, store them aside (diff)
Handle the new map return from the parser (use valid subkey)
-rw-r--r--lib/dmarc/parser.ex7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/dmarc/parser.ex b/lib/dmarc/parser.ex
index e4fd29b..cf2c521 100644
--- a/lib/dmarc/parser.ex
+++ b/lib/dmarc/parser.ex
@@ -7,11 +7,16 @@ defmodule Lithium.DMARC.Parser do
module to validate and process these values.
"""
+ require Logger
+
def parse_policy(record) do
case :dmarc_lexer.string(String.to_charlist(record)) do
{:ok, tokens, _} ->
case :dmarc_parser.parse(tokens) do
- {:ok, parsed} ->
+ {:ok, %{invalid: invalid_tokens, valid: parsed}} ->
+ if Kernel.map_size(invalid_tokens) > 0 do
+ Logger.warning("DMARC record contains invalid tokens: #{inspect(invalid_tokens)}")
+ end
{:ok, keyword_to_string_map(parsed)}
{:error, reason} ->