fix(muya): preserve drive/UNC roots in relative image path resolution (#4428 review follow-up) by Jocs · Pull Request #4430 · marktext/marktext · GitHub
Skip to content

fix(muya): preserve drive/UNC roots in relative image path resolution (#4428 review follow-up) - #4430

Merged
Jocs merged 1 commit into
developfrom
fix/muya-image-resolve-win-unc
Jun 9, 2026
Merged

Jocs merged 1 commit into
developfrom
fix/muya-image-resolve-win-unc

Conversation

@Jocs

@Jocs Jocs commented Jun 9, 2026

Copy link
Copy Markdown
Member

Fix-forward for a Copilot comment that landed on #4428 after merge. The new resolveRelativePath collapsed .. past the root: a Windows drive (C:/a/../../b lost the C: segment) and UNC //server/share roots got mangled. Now the root (UNC share / drive / POSIX) is isolated and never collapsed past, mirroring path.resolve. +6 regression cases (drive preservation, drive-root clamp, backslash normalisation, UNC share, backslash-UNC, UNC-root clamp). lint/lint:types/test green.

The Phase G #4428 relative-image resolver collapsed `..` past the root,
dropping the Windows drive segment (`C:/a/../../b` -> `b`, losing `C:`) and
mangling UNC `//server/share` bases. Isolate the root (UNC share / drive /
POSIX) before resolving and never collapse past it, mirroring path.resolve.
Adds 6 drive/UNC regression cases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 9, 2026 23:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fix-forward to packages/muya’s relative image path resolver so Windows drive roots (C:) and UNC share roots (//server/share) are preserved and .. traversal is clamped at the root (mirroring path.resolve behavior), preventing root segments from being collapsed away during normalization.

Changes:

  • Update resolveRelativePath to isolate and preserve UNC share / drive roots and prevent .. from collapsing past them.
  • Add regression tests covering drive preservation, drive-root clamp, backslash normalization, UNC share handling, and UNC-root clamp.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/muya/src/utils/image.ts Fix path resolution to preserve drive/UNC roots and clamp .. at the root.
packages/muya/src/utils/tests/image.spec.ts Add regression coverage for Windows drive + UNC base directory resolution edge cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Jocs
Jocs merged commit e2bd22d into develop Jun 9, 2026
8 checks passed
@Jocs
Jocs deleted the fix/muya-image-resolve-win-unc branch June 10, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants