mirror of
				https://github.com/disposable-email-domains/disposable-email-domains.git
				synced 2025-05-29 01:49:27 +08:00 
			
		
		
		
	Check for lines with third or lower level domains
This commit is contained in:
		
							parent
							
								
									f39c3d8ea5
								
							
						
					
					
						commit
						93debdb7e1
					
				
							
								
								
									
										22
									
								
								verify.py
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								verify.py
									
									
									
									
									
								
							@ -29,7 +29,6 @@ def check_for_public_suffixes(filename):
 | 
			
		||||
    lines = files[filename]
 | 
			
		||||
    suffix_detected = False
 | 
			
		||||
    psl = None
 | 
			
		||||
    download_suffixes()
 | 
			
		||||
    with open("public_suffix_list.dat", "r") as latest:
 | 
			
		||||
        psl = PublicSuffixList(latest)
 | 
			
		||||
    for i, line in enumerate(lines):
 | 
			
		||||
@ -49,6 +48,22 @@ def check_for_public_suffixes(filename):
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def check_for_third_level_domains(filename):
 | 
			
		||||
    with open("public_suffix_list.dat", "r") as latest:
 | 
			
		||||
        psl = PublicSuffixList(latest)
 | 
			
		||||
 | 
			
		||||
    invalid = {
 | 
			
		||||
        line
 | 
			
		||||
        for line in files[filename]
 | 
			
		||||
        if len(psl.privateparts(line.strip())) > 1
 | 
			
		||||
    }
 | 
			
		||||
    if invalid:
 | 
			
		||||
        print("The following domains contain a third or lower level domain in {!r}:".format(filename))
 | 
			
		||||
        for line in sorted(invalid):
 | 
			
		||||
            print("* {}".format(line))
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def check_for_non_lowercase(filename):
 | 
			
		||||
    lines = files[filename]
 | 
			
		||||
    invalid = set(lines) - set(line.lower() for line in lines)
 | 
			
		||||
@ -90,10 +105,15 @@ def check_for_intersection(filename_a, filename_b):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    # Download the list of public suffixes
 | 
			
		||||
    download_suffixes()
 | 
			
		||||
 | 
			
		||||
    # Check if any domains have a public suffix
 | 
			
		||||
    check_for_public_suffixes(blocklist)
 | 
			
		||||
 | 
			
		||||
    # Check if any domains are a third or lower level domain
 | 
			
		||||
    check_for_third_level_domains(blocklist)
 | 
			
		||||
 | 
			
		||||
    # Check if any domains are not lowercase
 | 
			
		||||
    check_for_non_lowercase(allowlist)
 | 
			
		||||
    check_for_non_lowercase(blocklist)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user