hermes - 💡(How to fix) Fix fix: Windows drive-letter paths not matched by MEDIA: tag and local file regex

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

When send_message is called with MEDIA:D:/desktop/file.docx, the regex fails to match because the path capture group (?:~/|/) requires the path to start with / or ~/. The MEDIA tag is not extracted, and the entire text (including MEDIA:...) is sent as plain text instead of a native file attachment.

Fix Action

Fix

Change both patterns from (?:~/|/) to (?:[A-Za-z]:[/\\\\]|~/|/).

Code Example

# CurrentUnix only
(?:~/|/)\\S+(?:[^\\S\\n]+\\S+)*?\\.(ext)

---

- (?:~/|/)\\S+(?:[^\\S\\n]+\\S+)*?\\.(?:ext)
+ (?:[A-Za-z]:[/\\\\]|~/|/)\\S+(?:[^\\S\\n]+\\S+)*?\\.(?:ext)

---

- (?<![/:\\w.])(?:~/|/)(?:[\\w.\\-]+/)*[\\w.\\-]+\\.(?:' + ext_part + r')\\b
+ (?<![/:\\w.])(?:[A-Za-z]:[/\\\\]|~/|/)(?:[\\w.\\-]+/)*[\\w.\\-]+\\.(?:' + ext_part + r')\\b
RAW_BUFFERClick to expand / collapse

Problem

The regex patterns in BasePlatformAdapter.extract_media() and BasePlatformAdapter.extract_local_files() only match paths starting with / or ~/ (Unix-style). On Windows, paths like D:\... or C:\... are silently ignored.

extract_media() — MEDIA:<path> tags

File: gateway/platforms/base.py, line ~2547

When send_message is called with MEDIA:D:/desktop/file.docx, the regex fails to match because the path capture group (?:~/|/) requires the path to start with / or ~/. The MEDIA tag is not extracted, and the entire text (including MEDIA:...) is sent as plain text instead of a native file attachment.

# Current — Unix only
(?:~/|/)\\S+(?:[^\\S\\n]+\\S+)*?\\.(ext)

extract_local_files() — bare path detection

File: gateway/platforms/base.py, line ~2618

Same issue: (?<![/:\\w.])(?:~/|/)(?:[\\w.\\-]+/)* only matches paths starting with / or ~/.

Fix

Change both patterns from (?:~/|/) to (?:[A-Za-z]:[/\\\\]|~/|/).

extract_media()

- (?:~/|/)\\S+(?:[^\\S\\n]+\\S+)*?\\.(?:ext)
+ (?:[A-Za-z]:[/\\\\]|~/|/)\\S+(?:[^\\S\\n]+\\S+)*?\\.(?:ext)

extract_local_files()

- (?<![/:\\w.])(?:~/|/)(?:[\\w.\\-]+/)*[\\w.\\-]+\\.(?:' + ext_part + r')\\b
+ (?<![/:\\w.])(?:[A-Za-z]:[/\\\\]|~/|/)(?:[\\w.\\-]+/)*[\\w.\\-]+\\.(?:' + ext_part + r')\\b

Verification

Tested on Windows 10 (git-bash) — after the fix, all three path formats work:

FormatExampleBeforeAfter
Windows driveMEDIA:D:/desktop/file.docxNoYes
Windows backslashMEDIA:D:\\desktop\\file.docxNoYes
Unix absoluteMEDIA:/tmp/file.docxYesYes
Tilde homeMEDIA:~/file.docxYesYes
Backtick-quotedMEDIA backtick D:/file.docx backtickYesYes

No regression — existing Unix paths continue to work.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix fix: Windows drive-letter paths not matched by MEDIA: tag and local file regex