Skip to content

fix TextDocumentUri to encode and decode special URI characters - #3062

Closed
ciuckc wants to merge 1 commit into
phpactor:masterfrom
ciuckc:master
Closed

fix TextDocumentUri to encode and decode special URI characters#3062
ciuckc wants to merge 1 commit into
phpactor:masterfrom
ciuckc:master

Conversation

@ciuckc

@ciuckc ciuckc commented Aug 13, 2026

Copy link
Copy Markdown

Issue

TextDocumentUri::__toString() builds file and phar URIs by splitting the path directly on '/'. Any filesyste m path that contains reserved characters will corrupt the URI if they are not encoded/decoded.

For example, a file within a directory that contains a '#' character would cause other clients to stop parsing at that symbol, thus truncating that path. In NeoVim, if you have a file under /home/#foo/baz.php and you run vim.lsp.buf.definition() on a symbol within baz.php, would cause the opening of a buffer in /home.

TextDocument::fromString() had the same issue but in reverse.

Fix

  • __toString() encodes each path segment for both file:// and phar://, preserving separators and other characters that dont need escaping (':', '@') important for Windows drive-letter paths like C:/foo.php.
  • fromString() now decodes each path segment on the way in.
  • Added test cases for '#', ' ', '%', and Windows drive letters.

file:// and phar:// were built without URI path percent encoding,
so any reserved character in a path segment (ex: '#', '?') could
corrupt the URIs and break LSP clients

@github-actions github-actions Bot 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.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Phpactor Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 0481eb8 Previous: 7eb622f Ratio
ConfigLoaderBench::benchJsonPlainPhp 0.015499726027397454 ms (± 1.52%) 0.007512211350293557 ms (± 3.28%) 2.06

This comment was automatically generated by workflow using github-action-benchmark.

@ciuckc ciuckc closed this Aug 13, 2026
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.

1 participant