diff --git a/jarvis/cogs/tags.py b/jarvis/cogs/tags.py index 512e302..3d25a30 100644 --- a/jarvis/cogs/tags.py +++ b/jarvis/cogs/tags.py @@ -23,6 +23,7 @@ invites = re.compile( r"(?:https?://)?(?:www.)?(?:discord.(?:gg|io|me|li)|discord(?:app)?.com/invite)/([^\s/]+?)(?=\b)", # noqa: E501 flags=re.IGNORECASE, ) +tag_name = re.compile(r"$[\w\ \-]{1,40}^") class TagCog(Extension): @@ -97,6 +98,9 @@ class TagCog(Extension): elif not content.strip() or not name.strip(): await response.send("Content and name required", ephemeral=True) return + elif not tag_name.match(name): + await response.send("Tag name must only contain: [A-Za-z0-9_- ]") + return tag = await Tag.find_one(q(guild=ctx.guild.id, name=name)) if tag: @@ -202,6 +206,9 @@ class TagCog(Extension): elif not content.strip() or not name.strip(): await response.send("Content and name required", ephemeral=True) return + elif not tag_name.match(name): + await response.send("Tag name must only contain: [A-Za-z0-9_- ]") + return tag.content = re.sub(r"\\?([@<])", r"\\\g<1>", content) tag.name = name