From 8a0125fc87c6a54ab84e48cd43e6af45404ca41a Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Wed, 25 Sep 2024 12:26:55 +0200 Subject: [PATCH] Fix code scanning alert Unvalidated dynamic method call --- server-data/resources/[gameplay]/chat/html/App.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server-data/resources/[gameplay]/chat/html/App.ts b/server-data/resources/[gameplay]/chat/html/App.ts index 031d59e2b..df685cc05 100644 --- a/server-data/resources/[gameplay]/chat/html/App.ts +++ b/server-data/resources/[gameplay]/chat/html/App.ts @@ -107,7 +107,12 @@ export default Vue.extend({ 'ON_OPEN' | 'ON_SCREEN_STATE_CHANGE' | 'ON_MESSAGE' | 'ON_CLEAR' | 'ON_SUGGESTION_ADD' | 'ON_SUGGESTION_REMOVE' | 'ON_TEMPLATE_ADD' | 'ON_UPDATE_THEMES' | 'ON_MODE_ADD' | 'ON_MODE_REMOVE'; - if (this[typeRef]) { + const validMethods = [ + 'ON_OPEN', 'ON_SCREEN_STATE_CHANGE', 'ON_MESSAGE', 'ON_CLEAR', 'ON_SUGGESTION_ADD', + 'ON_SUGGESTION_REMOVE', 'ON_TEMPLATE_ADD', 'ON_UPDATE_THEMES', 'ON_MODE_ADD', 'ON_MODE_REMOVE' + ]; + + if (validMethods.includes(typeRef) && typeof this[typeRef] === 'function') { this[typeRef](item); } };