Repository navigation
fix(connections): don't throw on a % that isn't an escape in a pasted connection string - #1391
Conversation
… connection string parseConnectionString decoded the username, password and database with decodeURIComponent, which throws URIError on a % that doesn't start a valid escape. Pasting postgres://user:pa%ss@host/db (a raw password, as people often paste them), a database named 50%off or sqlite:///tmp/50%.db threw out of the New Connection dialog's handler, so nothing was filled in and no error was shown. The URL parser passes such a part through unchanged, so a lenient decodeUriPart now keeps the text as typed when it isn't valid percent-encoding. Valid escapes (p%40ss, my%20db) are decoded as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
| * protocol of a group, the other members become aliases for the same | ||
| * driver (e.g. `postgresql://` works wherever `postgres://` does). | ||
| */ | ||
| /** |
There was a problem hiding this comment.
SUGGESTION: New helper was inserted between the PROTOCOL_ALIAS_GROUPS doc comment and its declaration
The existing JSDoc at lines 53-57 ("Groups of interchangeable URI schemes...") described PROTOCOL_ALIAS_GROUPS, but decodeUriPart and its own JSDoc are now placed between that comment and the constant, so the alias-group documentation is orphaned. Move decodeUriPart (with its doc comment) above line 53, or below PROTOCOL_ALIAS_GROUPS, so each doc comment stays attached to its declaration.
Code Review SummaryStatus: 1 Issue Found | Recommendation: Merge after addressing the minor suggestion Overview
The fix is correct: Issue Details (click to expand)SUGGESTION
Files Reviewed (2 files)
Fix these issues in Kilo Cloud Reviewed by claude-sonnet-5.5 · Input: 248 · Output: 2.4K · Cached: 239.7K Review guidance: REVIEW.md from base branch |
debba
left a comment
There was a problem hiding this comment.
Thanks for fixing this. Keeping a bare percent sign intact while still decoding valid escapes addresses a frustrating connection form failure, and the added cases make that distinction clear.
One small follow-up: the new decodeUriPart comment now sits between the protocol alias documentation and PROTOCOL_ALIAS_GROUPS. Please move the helper above that documentation so each comment stays attached to what it describes. This is a nit, not a blocker. I'll run the e2e checks before merging.
|
I tested this in the desktop app against PostgreSQL using a username, password and database name containing literal percent signs, then repeated it with |
…1443) Follow-up to #1391: the helper and its comment sat between the protocol alias documentation and PROTOCOL_ALIAS_GROUPS, separating that comment from what it describes. No behaviour change. Co-authored-by: Claude Opus 5.5 <[email protected]>
parseConnectionStringdecodes the username, password and database name withdecodeURIComponent, which throwsURIError: URI malformedon a%that doesn't start a valid escape. These all threw instead of returning a result:NewConnectionModalcalls the parser without atry, so pasting one of these into the connection-string field threw out of the handler. Nothing was filled in, and no error was shown.The WHATWG URL parser passes such a part through unchanged. A small
decodeUriParthelper now keeps that text as typed when it isn't valid percent-encoding, and decodes it otherwise, sop%40ssis stillp@ssandmy%20dbis stillmy db. It replaces the sixdecodeURIComponentcalls in the file (network URLs, passthrough display URLs and local file paths).Testing
tests/utils/connectionStringParser.test.ts(3 new tests): a password, username and database with a bare%are kept as typed; valid escapes are still decoded; a SQLite path with%works.pnpm typecheck✅, ESLint (no warnings) and Prettier on the changed files ✅.vitest run: 497 of 498 files and 8071 tests pass. The one failure istests/routing.test.ts, which timed out starting its local server under full-suite load on Windows. It passes 16/16 on its own and isn't touched here.AI assistance: found and written with Claude Code, tested as above.
🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.