Skip to content

Commit d33f6e8

Browse files
Lvl4Sworddermoth
authored andcommitted
Catch invalid query params (bitcoin-abe#267)
- Catch negative count -  prevents a server error when trying negative counts ( ?count=-1 for example ) - Catch invalid count or hi parameters (string or float) and force default
1 parent 9fc960d commit d33f6e8

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Abe/abe.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,19 @@ def handle_chain(abe, page):
415415
body = page['body']
416416
body += abe.search_form(page)
417417

418-
count = get_int_param(page, 'count') or 20
419-
if count >= 2017:
418+
try:
419+
count = get_int_param(page, 'count') or 20
420+
if count >= 2017:
421+
count = 20
422+
elif count <= 0:
423+
count = 20
424+
except ValueError:
420425
count = 20
421-
hi = get_int_param(page, 'hi')
426+
427+
try:
428+
hi = get_int_param(page, 'hi')
429+
except ValueError:
430+
hi = None
422431
orig_hi = hi
423432

424433
if hi is None:

0 commit comments

Comments
 (0)