import re
import sys

html = open(sys.argv[1], encoding="utf-8").read()

checks = {
    "<html>, <head> or <body> tags": r"<\s*(html|head|body)\b",
    "<style> or <title> tags": r"<\s*(style|title)\b",
    "<script> tags": r"<\s*script\b",
    "embedded (base64) images": r"src\s*=\s*[\"']data:",
    "images not linked with https://": r"<img[^>]+src\s*=\s*[\"'](?!https://)",
}

problems = 0
for name, pattern in checks.items():
    if re.search(pattern, html, re.I):
        print("PROBLEM:", name)
        problems += 1

print("Looks Gmail-safe." if problems == 0 else f"{problems} problem(s) found.")
