From 83b2096d2dacd69a3ccbbab1dd7db895ac999ba5 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Tue, 16 Aug 2022 13:41:22 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B05407=20-=20Mentions:=20Fix=20RegExp=20wi?= =?UTF-8?q?ldcard=20not=20usable=20as=20marker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/ckeditor.on-init.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/ckeditor.on-init.js b/js/ckeditor.on-init.js index 25131cdcd..4e519d82f 100644 --- a/js/ckeditor.on-init.js +++ b/js/ckeditor.on-init.js @@ -24,8 +24,15 @@ if ((CKEDITOR !== undefined) && (CKEDITOR.plugins.registered['disabler'] === und // Rewrite the CKEditor Mentions plugin regexp to make it suitable for all Unicode alphabets. if (CKEDITOR !== undefined && CKEDITOR.plugins.registered['mentions']) { - // from https://github.com/ckeditor/ckeditor4/blob/a3786007fb979d7d7bff3d10c34a2d422935baed/plugins/mentions/plugin.js#L147 + // From https://github.com/ckeditor/ckeditor4/blob/a3786007fb979d7d7bff3d10c34a2d422935baed/plugins/mentions/plugin.js#L147 function createPattern(marker, minChars) { + // Escape marker if it's a regex token + // https://github.com/tc39/proposal-regex-escaping/blob/main/EscapedChars.md#syntaxcharacter-proposal + const regexTokens = ['^', '$', '\\', '.', '*', '+', '?', '(', ')', '[', ']', '{', '}', '|']; + if (regexTokens.indexOf(marker) >= 0) { + marker = '\\' + marker; + } + let pattern = marker + '[\\p{L}\\p{N}_-]'; if ( minChars ) { pattern += '{' + minChars + ',}';