From 63ae4cbc3bde2037ff17840dcca80860bdd0a689 Mon Sep 17 00:00:00 2001 From: Martin Cech Date: Sun, 4 Feb 2018 22:09:52 -0500 Subject: [PATCH] strip line endings for comparison --- verify.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/verify.py b/verify.py index ef896cb..fd6d40c 100644 --- a/verify.py +++ b/verify.py @@ -3,16 +3,25 @@ """Verify the integrity of the domain blacklist """ +import io import sys from publicsuffixlist import PublicSuffixList def main(arguments): psl = PublicSuffixList() - with open("disposable_email_blacklist.conf", "r") as deb: - for line in deb: - if psl.publicsuffix(line) == line: - print(f'The following line is a public suffix: {line} - please remove it from the blacklist file. See https://publicsuffix.org for details.') + suffix_detected = False + + with io.open('disposable_email_blacklist.conf', 'r') as deb: + for i, line in enumerate(deb): + current_line = line.strip() + public_suffix = psl.publicsuffix(current_line) + if public_suffix == current_line: + print(f'The line number {i+1} contains just a public suffix: {current_line}') + suffix_detected = True + if suffix_detected: + print ('At least one valid public suffix found in the blacklist, please remove it. See https://publicsuffix.org for details on why this shouldn\'t be blacklisted.') + sys.exit(1) if __name__ == "__main__":