Skip to content

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

Description

@Govinda-Upadhya

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.

firstissue.mp4

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions