decode-spam-headers icon indicating copy to clipboard operation
decode-spam-headers copied to clipboard

"X-Forefront-Antispam-Report" failed: too many values to unpack (expected 2)

Open dniakamal opened this issue 9 months ago • 0 comments

An error occurs if the "X-Forefront-Antispam-Report" contains an IPv6 address which segments are separated by ":". The script returns an error, as only one ":" is allowed per segment in the "X-Forefront-Antispam-Report".

Debug Log:

[ERROR] Test 12: "X-Forefront-Antispam-Report" failed: too many values to unpack (expected 2) . Use --debug to show entire stack trace.
Traceback (most recent call last):
  File "decode-spam-headers.py", line 6960, in <module>
    main(sys.argv)
  File "decode-spam-headers.py", line 6940, in main
    out = an.parse(text)
  File "decode-spam-headers.py", line 2289, in parse
    self.results[testName] = testFunc()
  File "decode-spam-headers.py", line 5487, in testForefrontAntiSpamReport
    return self._parseAntiSpamReport(num, header, value)
  File "decode-spam-headers.py", line 5509, in _parseAntiSpamReport
    k, v = entry.split(':')
ValueError: too many values to unpack (expected 2)

To fix this, limit the split function to 1:

        for entry in value.split(';'):
            if len(entry.strip()) == 0: continue
-            k, v = entry.split(':')
+            k, v = entry.split(':', 1)
			
            if k not in parsed.keys():
                parsed[k] = v

Image

dniakamal avatar Mar 20 '25 14:03 dniakamal