diff options
| author | Mark Sapiro | 2017-01-01 22:18:09 -0800 |
|---|---|---|
| committer | Mark Sapiro | 2017-01-01 22:18:09 -0800 |
| commit | 9f2bba71bc52388b339e2e7167b86c8f88033e64 (patch) | |
| tree | d1eab4ffdb8ce6765988abc3b88bb015e2fc18d2 /src/mailman/rules/dmarc.py | |
| parent | f9cf79290eb7a22c4d52622dbef50367a086234d (diff) | |
| parent | c870e3cffce626ce85efa906e72a627e123edd6a (diff) | |
| download | mailman-9f2bba71bc52388b339e2e7167b86c8f88033e64.tar.gz mailman-9f2bba71bc52388b339e2e7167b86c8f88033e64.tar.zst mailman-9f2bba71bc52388b339e2e7167b86c8f88033e64.zip | |
Diffstat (limited to 'src/mailman/rules/dmarc.py')
| -rw-r--r-- | src/mailman/rules/dmarc.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/mailman/rules/dmarc.py b/src/mailman/rules/dmarc.py index 2739ff937..a213a235b 100644 --- a/src/mailman/rules/dmarc.py +++ b/src/mailman/rules/dmarc.py @@ -102,12 +102,13 @@ def ensure_current_suffix_list(): return cached_copy_path -def parse_suffix_list(): +def parse_suffix_list(filename=None): # Parse the suffix list into a per process cache. - cached_copy_path = ensure_current_suffix_list() + if filename is None: + filename = ensure_current_suffix_list() # At this point the cached copy must exist and is as valid as possible. # Read and return the contents as a UTF-8 string. - with open(cached_copy_path, 'r', encoding='utf-8') as fp: + with open(filename, 'r', encoding='utf-8') as fp: for line in fp: if not line.strip() or line.startswith('//'): continue @@ -121,8 +122,8 @@ def parse_suffix_list(): else: exception = False parts.reverse() - k = DOT.join(parts) - suffix_cache[k] = exception + key = DOT.join(parts) + suffix_cache[key] = exception def _get_dom(d, l): @@ -227,7 +228,13 @@ def _DMARCProhibited(mlist, email, dmarc_domain, org=False): if mo: policy = mo.group(1).lower() else: - continue + # This continue does actually get covered by + # TestDMARCRules.test_domain_with_subdomain_policy() and + # TestDMARCRules.test_no_policy() but because of + # Coverage BitBucket issue #198 and + # http://bugs.python.org/issue2506 coverage cannot report + # it as such, so just pragma it away. + continue # pragma: no cover if policy in ('reject', 'quarantine'): vlog.info( """%s: DMARC lookup for %s (%s) |
