diff options
author | Tomasz Kramkowski <tk@the-tk.com> | 2018-03-06 20:44:26 +0000 |
---|---|---|
committer | Tomasz Kramkowski <tk@the-tk.com> | 2018-03-06 20:44:26 +0000 |
commit | d429058e56536fc714a7370d41b6035a71b0c6d3 (patch) | |
tree | 6ffc137c5851d59255c3a4080146952f754f0cf5 | |
parent | 7fb0f2383264e8ae2f942613e7496072d0cefb8c (diff) | |
download | dmarcpipe-master.tar.gz dmarcpipe-master.tar.xz dmarcpipe-master.zip |
If an attachment of mime type 'application/octet-stream' is recognised
as 'application/octet-stream' then the program would enter into an
infinite loop and throw a RecursionError which likely wouldn't be too
bad but it's probably clearer to give a KeyError and mark the report
as invalid instead.
-rwxr-xr-x | dmarcpipe.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/dmarcpipe.py b/dmarcpipe.py index bbcc914..0178a1e 100755 --- a/dmarcpipe.py +++ b/dmarcpipe.py @@ -47,7 +47,12 @@ def zip2xml(data): return z.open(n[0]).read() gzip2xml = lambda data: gz_decompress(data) -octet_stream = lambda data: decode(data, magic(data).mime_type) + +def octet_stream(data): + mime = magic(data).mime_type + if mime == 'application/octet-stream': + raise KeyError + return decode(data, mime) decoders = { 'application/gzip': gzip2xml, |