-
Notifications
You must be signed in to change notification settings - Fork 410
Escape special characters in Monaco tokens and fix black screen in application #5085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Escape special characters in Monaco tokens and fix black screen in application #5085
Conversation
…plication An escapeRegex utility has been added and applied to all locations where command tokens are used to generate regex patterns in Monaco's token providers. This ensures that tokens containing special regex characters (such as *) do not cause errors. Additionally, this fix prevents the application from displaying a black screen when accessed.
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a critical bug where special regex characters in Redis command tokens caused Monaco editor to crash, resulting in a black screen in the application. An escapeRegex utility function is introduced and applied to all token-to-regex conversions in Monaco's language providers for both Redis and RediSearch commands.
Key Changes:
- Added
escapeRegexutility function to escape special regex characters in command tokens - Applied escaping to all locations where tokens are converted to regex patterns in Monaco providers
- Prevents regex syntax errors when command names contain special characters like
.*+?^${}()|[\]\
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| redisinsight/ui/src/utils/monaco/redisearch/utils.ts | Added escapeRegex utility and applied it to block token generation |
| redisinsight/ui/src/utils/monaco/monarchTokens/redisearchTokensTemplates.ts | Added escapeRegex utility and applied it to query generation |
| redisinsight/ui/src/utils/monaco/monacoRedisMonarchTokensProvider.ts | Added escapeRegex utility and applied it to command regex generation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| const escapeRegex = (str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') | ||
|
|
Copilot
AI
Oct 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The escapeRegex utility function is duplicated across three different files. Consider extracting it to a shared utility module (e.g., utils/regex.ts) and importing it to maintain DRY principles and ensure consistency.
| const escapeRegex = (str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') | |
| import { escapeRegex } from 'uiSrc/utils/regex' |
Copilot uses AI. Check for mistakes.
|
|
||
| // Escape special regex characters in tokens | ||
| const escapeRegex = (str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') | ||
|
|
Copilot
AI
Oct 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The escapeRegex utility function is duplicated across three different files. Consider extracting it to a shared utility module (e.g., utils/regex.ts) and importing it to maintain DRY principles and ensure consistency.
| // Escape special regex characters in tokens | |
| const escapeRegex = (str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') | |
| import { escapeRegex } from 'uiSrc/utils/regex' |
Copilot uses AI. Check for mistakes.
|
|
||
| const STRING_DOUBLE = 'string.double' | ||
|
|
||
| const escapeRegex = (str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') | ||
|
|
Copilot
AI
Oct 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The escapeRegex utility function is duplicated across three different files. Consider extracting it to a shared utility module (e.g., utils/regex.ts) and importing it to maintain DRY principles and ensure consistency.
| const STRING_DOUBLE = 'string.double' | |
| const escapeRegex = (str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') | |
| import { escapeRegex } from 'uiSrc/utils/regex' | |
| const STRING_DOUBLE = 'string.double' |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oriondesign2015 Thank you for contribution! we will get your changes as base for the fix
c969d6b
into
redis:fe/bugfix/RI-7669-fix-regex-issue-for-commands-json
An
escapeRegexutility has been added and applied to all locations where command tokens are used to generate regex patterns in Monaco's token providers.This prevents issues with tokens containing special regex characters.
Additionally, this fix prevents the application from displaying a black screen when accessed.
Related issues reporting the issue: