Skip to content

fix: add URL encoding to EmbeddedChatApi request parameters#1193

Open
sudorishabh wants to merge 1 commit intoRocketChat:developfrom
sudorishabh:fix/url-encoding-missing-in-EmbeddedChatApi
Open

fix: add URL encoding to EmbeddedChatApi request parameters#1193
sudorishabh wants to merge 1 commit intoRocketChat:developfrom
sudorishabh:fix/url-encoding-missing-in-EmbeddedChatApi

Conversation

@sudorishabh
Copy link

Brief Title

This PR fixes a bug where special characters (like &, #, or spaces) in search terms, room IDs, or usernames would break API requests because they weren't being URL-encoded.

Why needed?

Without encoding, a search for "Test & Fix" would result in a URL like .../chat.search?searchText=Test & Fix. The server sees the & and stops reading the search text, causing incomplete or failed results.

Fixes #1192

Affected Methods:

  • getSearchMessages (searchText, roomId)
  • getMessages / getOlderMessages (query, field, roomId)
  • getUsersInRole (role)
  • userData / userInfo (username, userId)
  • getThreadMessages (tmid)
  • getAllFiles (typeGroup, roomId)
  • Various other methods using this.rid in GET URLs (e.g., rooms.info, rooms.images, members).
// Before
`${this.host}/api/v1/chat.search?roomId=${this.rid}&searchText=${text}`

// After
`${this.host}/api/v1/chat.search?roomId=${encodeURIComponent(this.rid)}&searchText=${encodeURIComponent(text)}`

PR Test Details

Note: The PR will be ready for live testing at https://rocketchat.github.io/EmbeddedChat/pulls/pr-1192 after approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: Missing URI Encoding in EmbeddedChatApi.ts GET Requests

1 participant