fix: URL query parsing when values contain '='#7061
fix: URL query parsing when values contain '='#7061vmridul wants to merge 1 commit intoRocketChat:developfrom
Conversation
WalkthroughA query string parsing utility was updated to correctly handle parameters containing multiple Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
app/lib/methods/helpers/parseQuery.test.ts (1)
3-18: Optional: add one test for params without=.Since
parseQuerynow explicitly branches forseparatorIndex < 0, a case likeflag&token=abc==would make that path regression-safe too.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/lib/methods/helpers/parseQuery.test.ts` around lines 3 - 18, Add a unit test for parseQuery covering a parameter with no "=" (e.g., "flag&token=abc==") to exercise the separatorIndex < 0 branch; verify that parseQuery returns an object including the flag key with the expected empty-string value (or the implementation's chosen sentinel) and that the token value remains "abc==", using the parseQuery test suite where other cases live.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@app/lib/methods/helpers/parseQuery.test.ts`:
- Around line 3-18: Add a unit test for parseQuery covering a parameter with no
"=" (e.g., "flag&token=abc==") to exercise the separatorIndex < 0 branch; verify
that parseQuery returns an object including the flag key with the expected
empty-string value (or the implementation's chosen sentinel) and that the token
value remains "abc==", using the parseQuery test suite where other cases live.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 22ca5fae-0a82-495b-9a02-a3d7559709e2
📒 Files selected for processing (2)
app/lib/methods/helpers/parseQuery.test.tsapp/lib/methods/helpers/parseQuery.ts
📜 Review details
🔇 Additional comments (2)
app/lib/methods/helpers/parseQuery.test.ts (1)
4-17: Good regression coverage for this fix.The assertions on Line 5 and Line 13 correctly lock the bugfix behavior (
token=abc==) and the decode behavior for+/encoded values.app/lib/methods/helpers/parseQuery.ts (1)
18-20: Correct fix: split only on the first=.Using
indexOf+sliceon Line 18-Line 20 resolves truncation for values likeabc==while still handling params without=safely.
This PR fixes a bug where URL query values could be cut off when they contained
=Example:
parseQuery('host=open.rocket.chat&token=abc==&type=auth')Before:
{ host: 'open.rocket.chat', token: 'abc', type: 'auth' }After:
{ host: 'open.rocket.chat', token: 'abc==', type: 'auth' }I updated parseQuery to split only on the first
=I also added tests for these cases:
=and+still decode correctlyTypes of changes
Checklist
Summary by CodeRabbit
Bug Fixes
=characters and properly decode+signs and percent-encoded characters.Tests