From 261753e399b5727664238ed9b216defba4ac6343 Mon Sep 17 00:00:00 2001 From: Visual Date: Mon, 30 Mar 2020 17:13:39 +0000 Subject: [PATCH 1/3] Removed and fixed broken checks --- litecord/images.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/litecord/images.py b/litecord/images.py index 6b01327..a28bd48 100644 --- a/litecord/images.py +++ b/litecord/images.py @@ -333,7 +333,7 @@ class IconManager: *args, ) - if not icon_row: + if icon_row is None: return None icon = Icon(icon_row["key"], icon_row["hash"], icon_row["mime"]) @@ -371,9 +371,6 @@ class IconManager: # get an extension for the given data uri extension = get_ext(mime) - if "bsize" in kwargs and len(raw_data) > kwargs["bsize"]: - return _invalid(kwargs) - # size management is different for gif files # as they're composed of multiple frames. if "size" in kwargs and mime == "image/gif": @@ -529,3 +526,4 @@ class IconManager: await self.delete(old_icon) return await self.put(scope, key, new_icon_data, **kwargs) + From 0eccf157505ec777f430e6ca9dff023b7bafeb39 Mon Sep 17 00:00:00 2001 From: Visual Date: Mon, 30 Mar 2020 17:14:43 +0000 Subject: [PATCH 2/3] Fixed broken check --- litecord/blueprints/icons.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/litecord/blueprints/icons.py b/litecord/blueprints/icons.py index a01509e..ef38700 100644 --- a/litecord/blueprints/icons.py +++ b/litecord/blueprints/icons.py @@ -31,7 +31,7 @@ async def send_icon(scope, key, icon_hash, **kwargs): """Send an icon.""" icon = await app.icons.generic_get(scope, key, icon_hash, **kwargs) - if not icon: + if icon is None: return "", 404 return await send_file(icon.as_path) @@ -44,8 +44,6 @@ def splitext_(filepath): @bp.route("/emojis/", methods=["GET"]) async def _get_raw_emoji(emoji_file): - # emoji = app.icons.get_emoji(emoji_id, ext=ext) - # just a test file for now emoji_id, ext = splitext_(emoji_file) return await send_icon("emoji", emoji_id, None, ext=ext) @@ -110,3 +108,4 @@ async def _get_guild_splash(guild_id: int, icon_file: str): async def _get_guild_banner(guild_id: int, icon_file: str): icon_hash, ext = splitext_(icon_file) return await send_icon("banner", guild_id, icon_hash, ext=ext) + From fdb2afcd3666428664612f1711d18ab1a35bd10d Mon Sep 17 00:00:00 2001 From: Visual Date: Mon, 30 Mar 2020 17:16:43 +0000 Subject: [PATCH 3/3] Fixed broken check & query --- litecord/blueprints/guild/emoji.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/litecord/blueprints/guild/emoji.py b/litecord/blueprints/guild/emoji.py index db53c07..9f6bcf2 100644 --- a/litecord/blueprints/guild/emoji.py +++ b/litecord/blueprints/guild/emoji.py @@ -105,7 +105,7 @@ async def _put_emoji(guild_id): size=(128, 128), ) - if not icon: + if icon is None: return "", 400 # TODO: better way to detect animated emoji rather than just gifs, @@ -172,10 +172,11 @@ async def _del_emoji(guild_id, emoji_id): await app.db.execute( """ DELETE FROM guild_emoji - WHERE id = $2 + WHERE id = $1 """, emoji_id, ) await _dispatch_emojis(guild_id) return "", 204 +