fix TextDocumentUri to encode and decode special URI characters - #3062
Closed
ciuckc wants to merge 1 commit into
Closed
fix TextDocumentUri to encode and decode special URI characters#3062ciuckc wants to merge 1 commit into
ciuckc wants to merge 1 commit into
Conversation
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
Contributor
There was a problem hiding this comment.
⚠️ 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.phpand you runvim.lsp.buf.definition()on a symbol withinbaz.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 bothfile://andphar://, preserving separators and other characters that dont need escaping (':', '@') important for Windows drive-letter paths likeC:/foo.php.fromString()now decodes each path segment on the way in.