Skip to content

fix(core): encode reserved path chars in file URIs#151

Open
dergachoff wants to merge 1 commit into
bug-ops:mainfrom
dergachoff:fix/file-uri-reserved-path-chars
Open

fix(core): encode reserved path chars in file URIs#151
dergachoff wants to merge 1 commit into
bug-ops:mainfrom
dergachoff:fix/file-uri-reserved-path-chars

Conversation

@dergachoff
Copy link
Copy Markdown
Contributor

@dergachoff dergachoff commented May 8, 2026

Summary

Fixes #150.

path_to_uri formatted file URIs as file://{path}. Valid filesystem paths containing URI-reserved characters, such as bracketed route filenames, produced invalid raw URI paths. lsp_types::Uri::from_str then returned UnexpectedChar; because this path used expect, diagnostics requests could panic and abort the MCP stdio server.

This builds platform-aware file URLs with Url::from_file_path, preserves the existing Windows-rooted synthetic test-path behavior, encodes RFC3986-invalid path characters that WHATWG URL leaves raw in the path ([, ], ^, |), and adds a regression test for a route-style filename with uri_to_path round-trip coverage.

Validation

  • cargo +nightly fmt --check
  • cargo +1.95 test -p mcpls-core path_to_uri
  • cargo +1.95 test -p mcpls-core
  • cargo +1.95 clippy -p mcpls-core --all-targets --all-features -- -D warnings
  • rustup target add --toolchain 1.95 x86_64-pc-windows-msvc && cargo +1.95 check -p mcpls-core --target x86_64-pc-windows-msvc --all-targets --all-features
  • Manual MCP stdio probe: before the patch, get_diagnostics on a bracketed route path aborted with failed to create URI from path: ParseError { ... UnexpectedChar }; after the patch, the same call returned a normal tool response.

@github-actions github-actions Bot added rust Rust code changes mcpls-core mcpls-core crate changes labels May 8, 2026
@dergachoff dergachoff force-pushed the fix/file-uri-reserved-path-chars branch from aceae78 to 07196a4 Compare May 8, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mcpls-core mcpls-core crate changes rust Rust code changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_diagnostics can abort stdio server for file paths containing URI-reserved chars

1 participant