fix(intellij): handle square brackets in file paths for autocomplete#11474
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA. |
Use File.toURI() instead of URI constructor for Windows two-slash file:// URIs to properly percent-encode special characters like [ ]. Fixes continuedev#10978.
6e4b338 to
609cf8f
Compare
There was a problem hiding this comment.
2 issues found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/UriUtils.kt">
<violation number="1" location="extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/UriUtils.kt:30">
P1: `File(path).toURI()` reparses `file://` URI text as a host-local path, causing cross-platform URI corruption and double-encoding of already escaped segments.</violation>
</file>
<file name="extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt">
<violation number="1" location="extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt:85">
P2: Windows regression test assertions are too weak to catch drive-letter or bracket-handling regressions in `file://C:/...` URIs.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Verify that square brackets are percent-encoded and drive letter and directory structure are preserved in parsed URI path.
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt">
<violation number="1" location="extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt:86">
P2: Test incorrectly expects percent-encoded brackets in `URI.path`; `path` is decoded for `java.net.URI`, so this assertion is invalid.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
The CI runs on Linux where C: is not a drive letter. Assert that brackets are encoded and structure is preserved without platform-specific path assumptions.
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt">
<violation number="1" location="extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt:86">
P2: Windows bracket-path regression test was weakened and no longer asserts key Windows URI guarantees (encoding/preservation), allowing incorrect rewrites to pass.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
@Tarasusrus could you check the cubic comment? seems potentially valid |
File.toURI() is platform-dependent — on non-Windows hosts it treats Windows drive paths (e.g. C:/Users/...) as relative paths, producing corrupted URIs. The multi-arg URI(scheme, host, path, fragment) constructor is pure RFC 2396 string manipulation and works identically on all platforms. Also strengthens the Windows bracket test with exact equality assertions instead of loose contains/assertFalse checks.
RomneyDa
left a comment
There was a problem hiding this comment.
@Tarasusrus thanks for the contribution!
Use File.toURI() instead of URI constructor for Windows two-slash
file:// URIs to properly percent-encode special characters like [ ].
Fixes #10978.
Summary by cubic
Fixes URI parsing for file paths with square brackets to prevent IntelliJ autocomplete crashes on Windows two‑slash file URIs. Builds Windows
file://C:/...URIs with the cross‑platform multi‑argURI(...)constructor so[and]are percent‑encoded.UriUtilsto handle Windows two‑slashfile://URIs usingURI("file", "", "/$path", null)instead ofFile.toURI()to avoid host‑dependent behavior.Written for commit 2d6a66d. Summary will update on new commits.