From 6dbb855b8a3cc0eb0e8bed0fb0df92555c727633 Mon Sep 17 00:00:00 2001 From: Mia <49593536+mia-pi-git@users.noreply.github.com> Date: Mon, 1 Nov 2021 09:15:20 -0500 Subject: [PATCH] Helptickets: Adjust battle/replay regexes to check word boundaries This fixes a bug where the regex would see 'battle-gen8monotyperandombattle-numbers-pw' and would extract 2 urls; the 'battle-gen8monotyperandombattle-numbers-pw' and the 'battle-numbers-pw' from the end. The word boundary ensures it won't match within the format. --- server/chat-plugins/helptickets.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/chat-plugins/helptickets.ts b/server/chat-plugins/helptickets.ts index 8c27535d97..de13e6df2c 100644 --- a/server/chat-plugins/helptickets.ts +++ b/server/chat-plugins/helptickets.ts @@ -7,9 +7,9 @@ import type {PartialModlogEntry, ModlogID} from '../modlog'; const TICKET_FILE = 'config/tickets.json'; const TICKET_CACHE_TIME = 24 * 60 * 60 * 1000; // 24 hours const TICKET_BAN_DURATION = 48 * 60 * 60 * 1000; // 48 hours -const BATTLES_REGEX = /battle-(?:[a-z0-9]+)-(?:[0-9]+)(?:-[a-z0-9]+pw)?/g; +const BATTLES_REGEX = /\bbattle-(?:[a-z0-9]+)-(?:[0-9]+)(?:-[a-z0-9]{31}pw)?/g; const REPLAY_REGEX = new RegExp( - `${Utils.escapeRegex(Config.routes.replays)}/(?:[a-z0-9]-)?(?:[a-z0-9]+)-(?:[0-9]+)(?:-[a-z0-9]+pw)?`, "g" + `${Utils.escapeRegex(Config.routes.replays)}/(?:[a-z0-9]-)?(?:[a-z0-9]+)-(?:[0-9]+)(?:-[a-z0-9]{31}pw)?`, "g" ); Punishments.addPunishmentType({