From 9112ce22a400d66c82b429fae72e8637a34727c7 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sat, 12 Aug 2023 16:30:29 +0800 Subject: [PATCH] Avoiding accessing undefined tributeValues #26461 (#26462) Backport #26461 --- web_src/js/features/tribute.js | 2 +- web_src/js/utils/match.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web_src/js/features/tribute.js b/web_src/js/features/tribute.js index e77ba29950..09e0c08453 100644 --- a/web_src/js/features/tribute.js +++ b/web_src/js/features/tribute.js @@ -31,7 +31,7 @@ function makeCollections({mentions, emoji}) { if (mentions) { collections.push({ - values: window.config.tributeValues, + values: window.config.tributeValues ?? [], requireLeadingSpace: true, menuItemTemplate: (item) => { return ` diff --git a/web_src/js/utils/match.js b/web_src/js/utils/match.js index 31763b0940..fb177e3aeb 100644 --- a/web_src/js/utils/match.js +++ b/web_src/js/utils/match.js @@ -32,7 +32,7 @@ export function matchMention(queryText) { // results is a map of weights, lower is better const results = new Map(); - for (const obj of window.config.tributeValues) { + for (const obj of window.config.tributeValues ?? []) { const index = obj.key.toLowerCase().indexOf(query); if (index === -1) continue; const existing = results.get(obj);