fix: prevent crash when typing unknown slash commands#1152
Open
vivekyadav-3 wants to merge 17 commits intoRocketChat:developfrom
Open
fix: prevent crash when typing unknown slash commands#1152vivekyadav-3 wants to merge 17 commits intoRocketChat:developfrom
vivekyadav-3 wants to merge 17 commits intoRocketChat:developfrom
Conversation
…ecording consistency
…ChatBody, and fix emoji insertion at cursor
… authentication, commands, and message tools
- Added encodeURIComponent() to properly encode user input before appending to URL query string - Prevents special characters (&, ?, #, %) from breaking query parameters - Fixes issue RocketChat#1149
- Changed typing status timeout from 15000ms to 10000ms - Makes typing indicator more responsive and updates faster - Improves real-time chat experience
- Added defensive check to ensure selectedItem exists before accessing properties - Prevents TypeError when user types commands not in the filtered list - Fixes issue RocketChat#1144
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1144 – Prevent crash on unknown slash commands
While testing slash commands, I found a bug where entering a command that doesn’t exist (for example /hello) could crash the app with a TypeError.
Root cause
We were accessing properties on a command object without first confirming the command actually exists. When an unknown command was submitted, the code tried to read from undefined, which caused the crash.
Fix
Added a guard to ensure a command is selected before trying to use it:
if (selectedItem) {
handleCommandClick(selectedItem);
}
Now, if a user types an unknown slash command, the app safely ignores it instead of crashing.