mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-06 07:20:29 +03:00
sanitize string before used in regex to prevent crash (#2219)
This commit is contained in:
parent
d8d4bce287
commit
9fe67da98b
4 changed files with 13 additions and 5 deletions
|
|
@ -21,7 +21,7 @@ import {
|
|||
mxcUrlToHttp,
|
||||
} from '../utils/matrix';
|
||||
import { getMemberDisplayName } from '../utils/room';
|
||||
import { EMOJI_PATTERN, URL_NEG_LB } from '../utils/regex';
|
||||
import { EMOJI_PATTERN, sanitizeForRegex, URL_NEG_LB } from '../utils/regex';
|
||||
import { getHexcodeForEmoji, getShortcodeFor } from './emoji';
|
||||
import { findAndReplace } from '../utils/findAndReplace';
|
||||
import {
|
||||
|
|
@ -171,7 +171,7 @@ export const scaleSystemEmoji = (text: string): (string | JSX.Element)[] =>
|
|||
);
|
||||
|
||||
export const makeHighlightRegex = (highlights: string[]): RegExp | undefined => {
|
||||
const pattern = highlights.join('|');
|
||||
const pattern = highlights.map(sanitizeForRegex).join('|');
|
||||
if (!pattern) return undefined;
|
||||
return new RegExp(pattern, 'gi');
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue