mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-01 02:42:02 +08:00
fix: logs page crash when special chars present in the value of query (#4408)
This commit is contained in:
parent
d563778479
commit
79e6699b37
@ -122,8 +122,17 @@ export function replaceStringWithMaxLength(
|
|||||||
if (lastSearchValue === '') {
|
if (lastSearchValue === '') {
|
||||||
return `${mainString}${replacementString},`;
|
return `${mainString}${replacementString},`;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* We need to escape the special characters in the lastSearchValue else the
|
||||||
|
* new RegExp fails with error range out of order in char class
|
||||||
|
*/
|
||||||
|
const escapedLastSearchValue = lastSearchValue.replace(
|
||||||
|
/[-/\\^$*+?.()|[\]{}]/g,
|
||||||
|
'\\$&',
|
||||||
|
);
|
||||||
|
|
||||||
const updatedString = mainString.replace(
|
const updatedString = mainString.replace(
|
||||||
new RegExp(`${lastSearchValue}(?=[^${lastSearchValue}]*$)`),
|
new RegExp(`${escapedLastSearchValue}(?=[^${escapedLastSearchValue}]*$)`),
|
||||||
replacementString,
|
replacementString,
|
||||||
);
|
);
|
||||||
return `${updatedString},`;
|
return `${updatedString},`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user