From e5c9a4b57a7048aec636d687620515ec43275fab Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 12 Jun 2020 15:23:42 +0100 Subject: [PATCH] Perform regex match before trying to determine song length --- houdini/handlers/play/music.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/houdini/handlers/play/music.py b/houdini/handlers/play/music.py index f140bfa..9bcfa6a 100644 --- a/houdini/handlers/play/music.py +++ b/houdini/handlers/play/music.py @@ -207,15 +207,15 @@ async def handle_load_music_track(p, owner_id: int, track_id: int): @handlers.player_in_room(SoundStudio.DeckRoomId) @handlers.cooldown() async def handle_save_my_music_track(p, track_name, track_pattern, track_hash): + pattern_regex = r'^([0-9a-fA-F]+,[0-9a-fA-F]+\|){0,1000}[0-9a-fA-F]+,FFFF\|[0-9a-fA-F]+$' + if not re.match(pattern_regex, track_pattern): + return + encoded_track_pattern = encode_music_track(track_pattern) song_length = determine_song_length(track_pattern) if encoded_track_pattern != track_hash or song_length > 180: return - pattern_regex = r'^([0-9a-fA-F]+,[0-9a-fA-F]+\|){0,1000}[0-9a-fA-F]+,FFFF\|[0-9a-fA-F]+$' - if not re.match(pattern_regex, track_pattern): - return - track_count = await db.select([db.func.count(PenguinTrack.id)])\ .where(PenguinTrack.owner_id == p.id).gino.scalar() if track_count >= 12: