diff --git a/app.py b/app.py index 2a085cb..3f283a6 100644 --- a/app.py +++ b/app.py @@ -8,6 +8,8 @@ APP_DIR = r"C:\cookievault" DB_PATH = os.path.join(APP_DIR, "cookies.db") WATCH_DIR = os.path.join(APP_DIR, "incoming") SESSION_DIR = os.path.join(APP_DIR, "sessions") +WORK_DRIVE = r"D:\\" # the "Work" removable drive +SCAN_ROOTS = [WATCH_DIR, WORK_DRIVE] os.makedirs(WATCH_DIR, exist_ok=True) os.makedirs(SESSION_DIR, exist_ok=True) @@ -49,11 +51,28 @@ def parse_netscape(text): out.append((domain, flag, path, secure, expiry, name, value)) return out +def _safe_expiry(val): + try: + iv = int(float(val)) + return iv if iv > 0 else 0 + except (TypeError, ValueError): + return 0 + def import_file(path): fname = os.path.basename(path) with open(path, "r", encoding="utf-8", errors="replace") as f: text = f.read() cookies = parse_netscape(text) + # guard: every cookie must have sane types (name+value non-empty, expiry numeric-ish) + clean = [] + for ck in cookies: + if not ck[5] or not ck[6]: + continue + if re.match(r"^[0-9]+$", ck[4].strip() or "0") is None: + # header junk line that survived parsing (e.g. split words) — skip + continue + clean.append(ck) + cookies = clean c = db() before = c.execute("SELECT COUNT(*) FROM cookies").fetchone()[0] for ck in cookies: @@ -98,7 +117,10 @@ td.val{color:#9ece6a;max-width:240px;overflow:hidden;text-overflow:ellipsis;whit
also watches C:\cookievault\incoming — dump files there and hit rescan
- + + 📁 PICK FOLDER ON WORK DRIVE + + smart scan: any .txt containing Netscape cookies gets imported, whatever its name {% if msg %}{{msg|safe}}
{% endif %}