summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2025-09-26 03:08:25 -0400
committerJohn Turner <jturner.usa@gmail.com>2025-09-26 03:08:25 -0400
commit10f54a354d4668fdee2d51750d9064cc2e8b6a88 (patch)
tree167b1aac4fda3eff884b300b0a2a291624d92f10
parentd2ea83e3f1177bc2f1eff97c0f2ca14e3aa32d00 (diff)
downloadpypaste-10f54a354d4668fdee2d51750d9064cc2e8b6a88.tar.gz
handle invalid keys by returning HTTPBadRequest
-rw-r--r--pypaste/server/__init__.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/pypaste/server/__init__.py b/pypaste/server/__init__.py
index 582d4f8..1c40f71 100644
--- a/pypaste/server/__init__.py
+++ b/pypaste/server/__init__.py
@@ -160,7 +160,13 @@ class App:
return web.HTTPBadRequest(text="provide a key to fetch")
try:
- paste = await self.storage.retrieve(dehumanize(key))
+ dehumanized_key = dehumanize(key)
+ except Exception as e:
+ log_warning(f"invalid key parameter: {key}: {e}")
+ return web.HTTPBadRequest(text="invalid key")
+
+ try:
+ paste = await self.storage.retrieve(dehumanized_key)
except Exception as e:
log_error(f"failed to retrieve paste {key}: {e}")
return web.HTTPInternalServerError()