RocketChat / RocketChat/EmbeddedChat
bug: search queries with &, #, or + return wrong results — URL params not encoded
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 165
- Forks
- 381
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 1
Description
Searching for anything with &, #, or + in it returns wrong results or nothing at all.
getSearchMessages in EmbeddedChatApi.ts (line 1124) builds the URL with a template literal:
`${this.host}/api/v1/chat.search?roomId=${this.rid}&searchText=${text}`
The text param goes straight into the URL without encoding. So:
hello & goodbye— the&starts a new query param. Server receivessearchText=helloand a straygoodbyeparam#channel— the#is treated as a URL fragment.searchTextarrives as an empty stringhello world+test— the+is read as a space. Server getshello world test
Same pattern in three other methods:
getUserStatus(line 1236) —userId=${reqUserId}userInfo(line 1253) —userId=${reqUserId}userData(line 1270) —username=${username}
The userId ones are less likely to hit this in practice since IDs are usually alphanumeric, but usernames with special characters would break userData.
File: packages/api/src/EmbeddedChatApi.ts
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/api/src/EmbeddedChatApi.ts at getSearchMessages and review the URL construction in getUserStatus, userInfo, and userData. Verify the behavior with values containing &, #, and +; done means these values reach the API as the intended search text, user ID, or username rather than altering the query.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100