Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
util: Do not use look-behind in wildcard mention checks.
Alex Vandiver01860422af92
diff --git a/web/src/util.ts b/web/src/util.tsindex d7f47a7f17c..8a3655b9b78 100644--- a/web/src/util.ts+++ b/web/src/util.ts@@ -195,7 +195,10 @@ export class CachedValue<T> {}export function find_stream_wildcard_mentions(message_content: string): string | null {- const mention = message_content.match(/(?<![^\s"'(/<[{])(@\*{2}(all|everyone|stream)\*{2})/);+ // We cannot use the exact same regex as the server side users (in zerver/lib/mention.py)+ // because Safari < 16.4 does not support look-behind assertions. Reframe the lookbehind of a+ // negative character class as a start-of-string or positive character class.+ const mention = message_content.match(/(?:^|[\s"'(/<[{])(@\*{2}(all|everyone|stream)\*{2})/);if (mention === null) {return null;}diff --git a/web/tests/util.test.js b/web/tests/util.test.jsindex 357bd7d7dfc..b5251385b6d 100644--- a/web/tests/util.test.js+++ b/web/tests/util.test.js@@ -170,6 +170,8 @@ run_test("wildcard_mentions_regexp", () => {"@**everyone**",'"@**everyone**"',"@**everyone**: Look at this!",+ "The <@**everyone**> channel",+ 'I have to say "@**everyone**" to ding the bell',"some text before @**everyone** some text after","@**everyone** some text after only","some text before only @**everyone**",