From aba4d0cda1fbdf516f05af3e64cbbfaca219ea8b Mon Sep 17 00:00:00 2001 From: TowyTowy Date: Wed, 15 Jul 2026 11:31:52 +0200 Subject: [PATCH] fix(scan): strip leading dot from dot-separated version tags VERSION_TAG_REGEX only treated whitespace, underscore, and hyphen as separators after the version prefix, so a dot-separated tag like "(v.1.0)" or "(Ver. 1.00)" fell through to the no-separator branch and captured the dot into the version (".1.0", ". 1.00"). This wrong value was then persisted to Rom.version on scan and on rename. Add "." to the separator character class so the dot is consumed like the other separators. Digit-prefixed tags such as "(v1.0)" are unaffected (they still match the no-separator branch), and non-version "v*" tags are still ignored. Co-Authored-By: Claude --- backend/handler/filesystem/roms_handler.py | 2 +- .../handler/filesystem/test_roms_handler.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/backend/handler/filesystem/roms_handler.py b/backend/handler/filesystem/roms_handler.py index 4c951fbea..ae2992e91 100644 --- a/backend/handler/filesystem/roms_handler.py +++ b/backend/handler/filesystem/roms_handler.py @@ -141,7 +141,7 @@ def _make_file_hash( GENERIC_TAG_REGEX = re.compile(r"\(([^)]+)\)|\[([^]]+)\]") -VERSION_TAG_REGEX = re.compile(r"^(?:version|ver|v)(?:[\s_-](.*)|([.\d].*))", re.I) +VERSION_TAG_REGEX = re.compile(r"^(?:version|ver|v)(?:[\s._-](.*)|([.\d].*))", re.I) REGION_TAG_REGEX = re.compile(r"^reg[\s|-](.*)$", re.I) REVISION_TAG_REGEX = re.compile(r"^rev[\s|-](.*)$", re.I) diff --git a/backend/tests/handler/filesystem/test_roms_handler.py b/backend/tests/handler/filesystem/test_roms_handler.py index b1f0c032d..61af31110 100644 --- a/backend/tests/handler/filesystem/test_roms_handler.py +++ b/backend/tests/handler/filesystem/test_roms_handler.py @@ -241,6 +241,24 @@ class TestFSRomsHandler: parsed_tags = handler.parse_tags(fs_name) assert parsed_tags.version == "1.2.3" + # A dot separator (e.g. "v.1.0", "Ver. 1.00") must not leak into the + # version as a leading dot. + fs_name = "My Game (v.1.2.3).rom" + parsed_tags = handler.parse_tags(fs_name) + assert parsed_tags.version == "1.2.3" + + fs_name = "My Game (Ver.1.2.3).rom" + parsed_tags = handler.parse_tags(fs_name) + assert parsed_tags.version == "1.2.3" + + fs_name = "My Game (Ver. 1.00).rom" + parsed_tags = handler.parse_tags(fs_name) + assert parsed_tags.version == "1.00" + + fs_name = "My Game (Version.2).rom" + parsed_tags = handler.parse_tags(fs_name) + assert parsed_tags.version == "2" + def test_parse_tags_non_version_tags_starting_with_v(self, handler: FSRomsHandler): """Test parse_tags keeps non-version tags starting with v as generic tags""" fs_name = "Rom [2026] [Variation].rom"