From 2d17e0e9d9998975e8ce14dfe089d34904ae9bdf Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Tue, 31 Mar 2026 14:17:24 +0200 Subject: [PATCH] fix: trust full MD5 for cross-name variant resolution --- scripts/common.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/common.py b/scripts/common.py index 9ccb98ac..84eea6d9 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -436,8 +436,12 @@ def resolve_local_file( sha1_match = by_md5.get(md5_candidate) if sha1_match and sha1_match in files_db: path = files_db[sha1_match]["path"] - if os.path.exists(path) and _md5_name_ok(path): - return path, "md5_exact" + # Full MD5 (32 chars) is a strong identifier: trust it + # without name guard. Truncated MD5 still needs name check + # to avoid cross-contamination. + if os.path.exists(path): + if len(md5_candidate) >= 32 or _md5_name_ok(path): + return path, "md5_exact" if len(md5_candidate) < 32: for db_md5, db_sha1 in by_md5.items(): if db_md5.startswith(md5_candidate) and db_sha1 in files_db: