RocketChat / RocketChat/EmbeddedChat

bug: search queries with &, #, or + return wrong results — URL params not encoded

Open Beginner friendly
#1,276 0 comments 0 reactions 0 assignees View on GitHub

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 receives searchText=hello and a stray goodbye param
  • #channel — the # is treated as a URL fragment. searchText arrives as an empty string
  • hello world+test — the + is read as a space. Server gets hello 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.