import subprocess r = subprocess.run( ["curl", "-s", "http://127.0.0.1:5000/chat", "--connect-timeout", "5", "--max-time", "10"], capture_output=True, text=True, timeout=15 ) html = r.stdout bugs = [] # Check key elements for elem in ["msgList", "msgInput", "sendBtn", "convList", "emptyState"]: search = 'id="' + elem + '"' if search not in html: bugs.append("MISSING ELEMENT: id=" + elem) else: print("OK: id=" + elem + " found") # Check key JS functions for fn in ["sendMessage", "handleKeyDown", "loadMessages", "selectConversation", "renderMsg"]: if ("function " + fn) in html or (fn + "(") in html: print("OK: " + fn + " found") else: bugs.append("MISSING FUNCTION: " + fn) # Check for onclick backslash (dangerous pattern) import re onclick_matches = re.findall(r'onclick="[^"]*\\\\[^"]*"', html) if onclick_matches: bugs.append("DANGEROUS ONCLICK: " + str(len(onclick_matches)) + " matches") else: print("OK: No dangerous onclick patterns") # Check for triple-escape style bug if 'style=' in html: style_sections = re.findall(r'style=[^>]+', html) for s in style_sections: if s.count('\\\\') >= 3: bugs.append("STYLE BACKSLASH BUG: " + s[:50]) break else: print("OK: No style backslash bug") # Check S6 specific features for feat in ["EventSource", "typing-dots", "msg-list", "input-area", "stream", "msg-bubble"]: if feat in html: print("OK: feature " + feat + " present") else: print("WARN: feature " + feat + " missing") if bugs: print("\nBUGS FOUND:") for b in bugs: print(" " + b) else: print("\nVERIFY: ALL CLEAN") # Check HTTP status r2 = subprocess.run( ["curl", "-s", "-o", "/dev/null", "-w", "%{http_code}", "http://127.0.0.1:5000/chat"], capture_output=True, text=True, timeout=10 ) print("HTTP status: " + r2.stdout.strip())