Restrict tag name characters
This commit is contained in:
parent
89f0bf59d3
commit
73e8cd87d1
1 changed files with 7 additions and 0 deletions
|
@ -23,6 +23,7 @@ invites = re.compile(
|
||||||
r"(?:https?://)?(?:www.)?(?:discord.(?:gg|io|me|li)|discord(?:app)?.com/invite)/([^\s/]+?)(?=\b)", # noqa: E501
|
r"(?:https?://)?(?:www.)?(?:discord.(?:gg|io|me|li)|discord(?:app)?.com/invite)/([^\s/]+?)(?=\b)", # noqa: E501
|
||||||
flags=re.IGNORECASE,
|
flags=re.IGNORECASE,
|
||||||
)
|
)
|
||||||
|
tag_name = re.compile(r"$[\w\ \-]{1,40}^")
|
||||||
|
|
||||||
|
|
||||||
class TagCog(Extension):
|
class TagCog(Extension):
|
||||||
|
@ -97,6 +98,9 @@ class TagCog(Extension):
|
||||||
elif not content.strip() or not name.strip():
|
elif not content.strip() or not name.strip():
|
||||||
await response.send("Content and name required", ephemeral=True)
|
await response.send("Content and name required", ephemeral=True)
|
||||||
return
|
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))
|
tag = await Tag.find_one(q(guild=ctx.guild.id, name=name))
|
||||||
if tag:
|
if tag:
|
||||||
|
@ -202,6 +206,9 @@ class TagCog(Extension):
|
||||||
elif not content.strip() or not name.strip():
|
elif not content.strip() or not name.strip():
|
||||||
await response.send("Content and name required", ephemeral=True)
|
await response.send("Content and name required", ephemeral=True)
|
||||||
return
|
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.content = re.sub(r"\\?([@<])", r"\\\g<1>", content)
|
||||||
tag.name = name
|
tag.name = name
|
||||||
|
|
Loading…
Add table
Reference in a new issue