Skip to content

Conversation

@oriondesign2015
Copy link
Contributor

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 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:

…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.
@CLAassistant
Copy link

CLAassistant commented Oct 21, 2025

CLA assistant check
All committers have signed the CLA.

@jit-ci
Copy link

jit-ci bot commented Oct 21, 2025

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.

Copy link
Contributor

Copilot AI left a 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 escapeRegex utility 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.

Comment on lines 7 to +9

const escapeRegex = (str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')

Copy link

Copilot AI Oct 21, 2025

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.

Suggested change
const escapeRegex = (str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
import { escapeRegex } from 'uiSrc/utils/regex'

Copilot uses AI. Check for mistakes.

Comment on lines 5 to +8

// Escape special regex characters in tokens
const escapeRegex = (str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')

Copy link

Copilot AI Oct 21, 2025

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.

Suggested change
// 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.

Comment on lines 5 to +9

const STRING_DOUBLE = 'string.double'

const escapeRegex = (str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')

Copy link

Copilot AI Oct 21, 2025

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.

Suggested change
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.

@ArtemHoruzhenko ArtemHoruzhenko changed the base branch from main to fe/bugfix/RI-7669-fix-regex-issue-for-commands-json October 21, 2025 14:02
Copy link
Collaborator

@ArtemHoruzhenko ArtemHoruzhenko left a 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

@ArtemHoruzhenko ArtemHoruzhenko merged commit c969d6b into redis:fe/bugfix/RI-7669-fix-regex-issue-for-commands-json Oct 21, 2025
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-frontend-tests Trigger the CI to run the front-end tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants