fix(intellij): handle square brackets in file paths for autocomplete#11474
fix(intellij): handle square brackets in file paths for autocomplete#11474Tarasusrus wants to merge 3 commits intocontinuedev:mainfrom
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.
| if (uriStr.startsWith("file://") && !uriStr.startsWith("file:///")) { | ||
| val path = uriStr.substringAfter("file://") | ||
| return URI("file:///$path") | ||
| return File(path).toURI() |
There was a problem hiding this comment.
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.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/UriUtils.kt, line 30:
<comment>`File(path).toURI()` reparses `file://` URI text as a host-local path, causing cross-platform URI corruption and double-encoding of already escaped segments.</comment>
<file context>
@@ -23,10 +23,11 @@ object UriUtils {
if (uriStr.startsWith("file://") && !uriStr.startsWith("file:///")) {
val path = uriStr.substringAfter("file://")
- return URI("file:///$path")
+ return File(path).toURI()
}
</file context>
...tellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt
Outdated
Show resolved
Hide resolved
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.
...tellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt
Outdated
Show resolved
Hide resolved
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.
| val parsed = UriUtils.parseUri(uri) | ||
| assertEquals("file", parsed.scheme) | ||
| // Brackets must be percent-encoded or absent as raw characters in a valid URI | ||
| assertFalse("Raw square brackets should not appear in URI path", |
There was a problem hiding this comment.
P2: Windows bracket-path regression test was weakened and no longer asserts key Windows URI guarantees (encoding/preservation), allowing incorrect rewrites to pass.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At extensions/intellij/src/test/kotlin/com/github/continuedev/continueintellijextension/unit/UriUtilsTest.kt, line 86:
<comment>Windows bracket-path regression test was weakened and no longer asserts key Windows URI guarantees (encoding/preservation), allowing incorrect rewrites to pass.</comment>
<file context>
@@ -82,11 +82,12 @@ class UriUtilsTest : TestCase() {
- parsed.path.contains("C:") || parsed.path.contains("c:"))
- assertTrue("Path should preserve full directory structure",
+ // Brackets must be percent-encoded or absent as raw characters in a valid URI
+ assertFalse("Raw square brackets should not appear in URI path",
+ parsed.toString().contains("[") || parsed.toString().contains("]"))
+ assertTrue("Path should preserve directory structure",
</file context>
|
@Tarasusrus could you check the cubic comment? seems potentially valid |
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 viaFile.toURI()so[and]are percent‑encoded.UriUtilsto handle Windows two‑slashfile://URIs usingFile.toURI()instead ofURI(...).Written for commit a00c389. Summary will update on new commits.