aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2019-06-16 13:54:53 -0700
committerGravatar MarkKoz <[email protected]>2019-06-16 13:54:53 -0700
commit6dccbd38016b113983b195f15272a5f432df6dcb (patch)
tree62cf2a21079510afd5d5a884006ddf04269780e7
parentSnekbox: remove code template (diff)
Snekbox: limit paste service uploads to 1000 characters
-rw-r--r--bot/cogs/snekbox.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py
index e10c6c2aa..0f8d3e4b6 100644
--- a/bot/cogs/snekbox.py
+++ b/bot/cogs/snekbox.py
@@ -38,6 +38,7 @@ RAW_CODE_REGEX = re.compile(
)
BYPASS_ROLES = (Roles.owner, Roles.admin, Roles.moderator, Roles.helpers)
+MAX_PASTE_LEN = 1000
class Snekbox:
@@ -60,6 +61,10 @@ class Snekbox:
"""Upload the eval output to a paste service and return a URL to it if successful."""
log.trace("Uploading full output to paste service...")
+ if len(output) > MAX_PASTE_LEN:
+ log.info("Full output is too long to upload")
+ return "too long to upload"
+
url = URLs.paste_service.format(key="documents")
try:
async with self.bot.http_session.post(url, data=output, raise_for_status=True) as resp:
@@ -68,7 +73,7 @@ class Snekbox:
if "key" in data:
return URLs.paste_service.format(key=data["key"])
except Exception:
- # 400 (Bad Request) means the data is too large
+ # 400 (Bad Request) means there are too many characters
log.exception("Failed to upload full output to paste service!")
@staticmethod