RocketChat / RocketChat/Rocket.Chat

Bug Report: File search fails due to unescaped special characters (parentheses) and untrimmed whitespace in chat room

Open
#41,536 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

Description:

When searching for files inside a chat room, the search input field does not sanitize or normalize the query string. This causes two distinct functional failures:
1.Untrimmed Spaces: Accidentally typing leading or trailing whitespaces results in an empty search state because the system treats the spaces as part of the literal filename.
2.Regex Evaluation Breakage: Special regular expression characters—specifically parentheses () commonly found in OS-duplicated files (e.g., file(1).pdf)—are not escaped.

Steps to reproduce:
  1. Create a direct message room with another user.
  2. Send files and videos to each other, some of the filename should have special character like parenthesis.
  3. Search for files by clicking on the top right of the chatroom.
  4. Try searching for a file with exact name but with leading or trailing white space. Also try searching for the file whose name has a parenthesis.
Expected behavior:

Expected behavior for the search functionality is to ignore the white space and then display the result. Also the parenthesis should be treated as a string and then they should display the required result.

Actual behavior:

For both searches the system returns empty results.

https://github.com/user-attachments/assets/34d88f1a-5266-4339-a948-88ef2981186e

Server Setup Information:
  • Version of Rocket.Chat Server: 8.7.0-develop
  • License Type:Community
  • Number of Users: 2
  • Operating System: Fedora
  • Deployment Method: Development
  • Number of Running Instances: 1
  • DB Replicaset Oplog:
  • NodeJS Version: 22.22.3
  • MongoDB Version:
Client Setup Information
  • Browser: Firefox
  • Operating System: Fedora 43

Contributor guide

Open the contributing guide

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 from the chat room file-search input described in the reproduction steps and trace how its query is handled. Verify the behavior with filenames containing leading or trailing whitespace and parentheses; done means trimmed searches return matching files and parentheses are treated literally instead of producing empty results.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, search
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.