Skip to content

Commit a6951bf

Browse files
committed
This PR improves the regex detection used for the drive_sep_replace default.
1 parent edbf737 commit a6951bf

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

beets/dbcore/db.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ def _get_formatted(self, model: Model, key: str) -> str:
159159
sep_repl: str = beets.config["path_sep_replace"].as_str()
160160
sep_drive: str = beets.config["drive_sep_replace"].as_str()
161161

162-
if re.match(r"^\w:", value):
163-
value = re.sub(r"(?<=^\w):", sep_drive, value)
162+
if re.match(r"^[a-zA-Z]:", value):
163+
value = re.sub(r"(?<=[a-zA-Z]):", sep_drive, value)
164164

165165
for sep in (os.path.sep, os.path.altsep):
166166
if sep:

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ Bug fixes
6060
``duplicate_action`` config options were silently ignored for as-is imports.
6161
- :doc:`/plugins/convert`: Fix extension substitution inside path of the
6262
exported playlist.
63+
- :ref:`replace`: Made ``drive_sep_replace`` regex logic more precise to
64+
prevent edge-case mismatches (e.g., a song titled "1:00 AM" would incorrectly
65+
be considered a Windows drive path).
6366

6467
For plugin developers
6568
~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)