[snapshot/master] Handle evil unicode (or other non-ascii) chars in URLs: return 404
---
web/app/snapshot/model/snapshotmodel.py | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/web/app/snapshot/model/snapshotmodel.py b/web/app/snapshot/model/snapshotmodel.py
index c68c056..aa357f8 100644
--- a/web/app/snapshot/model/snapshotmodel.py
+++ b/web/app/snapshot/model/snapshotmodel.py
@@ -234,9 +234,12 @@ class SnapshotModel:
if path == "":
path = '/'
- stat = db.query_one("""SELECT filetype, path, directory_id, node_id, digest, size FROM stat(%(path)s, %(mirrorrun_id)s)""",
- { 'mirrorrun_id': mirrorrun_id,
- 'path': path } )
+ try:
+ stat = db.query_one("""SELECT filetype, path, directory_id, node_id, digest, size FROM stat(%(path)s, %(mirrorrun_id)s)""",
+ { 'mirrorrun_id': mirrorrun_id,
+ 'path': path } )
+ except UnicodeEncodeError:
+ return None
if stat['filetype'] is None:
return None
--
1.7.2.5
Reply to: