Additional checking of digit string lengths

merge-requests/28/head
Bob Mottram 2022-09-08 11:34:12 +01:00
parent 0aed7b03ea
commit 0baec75b68
6 changed files with 52 additions and 7 deletions

View File

@ -17617,7 +17617,7 @@ class PubServer(BaseHTTPRequestHandler):
if reply_handle not in reply_to_list:
reply_to_list.append(reply_handle)
if ment.startswith('page='):
reply_page_str = ment.replace('page=', '')
reply_page_str = ment.replace('page=', '')
if len(reply_page_str) > 5:
reply_page_str = "1"
if reply_page_str.isdigit():

View File

@ -1701,9 +1701,13 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
post_index_str = command_str.split('read ')[1]
else:
post_index_str = command_str.split('show ')[1]
if len(post_index_str) > 5:
post_index_str = "1"
if box_json and post_index_str.isdigit():
_desktop_clear_screen()
_desktop_show_banner()
if len(post_index_str) > 5:
post_index_str = "1"
post_index = int(post_index_str)
post_json_object = \
_read_local_box_post(session, nickname, domain,
@ -1764,6 +1768,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
elif not actor_json and box_json:
_desktop_clear_screen()
_desktop_show_banner()
if len(post_index_str) > 5:
post_index_str = "1"
post_index = int(post_index_str)
actor_json = \
_desktop_show_profile(session, nickname, domain,
@ -1870,6 +1876,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
curr_index = 0
if ' ' in command_str:
post_index = command_str.split(' ')[-1].strip()
if len(post_index) > 5:
post_index = "1"
if post_index.isdigit():
curr_index = int(post_index)
if curr_index > 0 and box_json:
@ -1909,6 +1917,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
curr_index = 0
if ' ' in command_str:
post_index = command_str.split(' ')[-1].strip()
if len(post_index) > 5:
post_index = "1"
if post_index.isdigit():
curr_index = int(post_index)
if curr_index > 0 and box_json:
@ -1941,6 +1951,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
curr_index = 0
if ' ' in command_str:
post_index = command_str.split(' ')[-1].strip()
if len(post_index) > 5:
post_index = "1"
if post_index.isdigit():
curr_index = int(post_index)
if curr_index > 0 and box_json:
@ -1983,6 +1995,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
curr_index = 0
if ' ' in command_str:
post_index = command_str.split(' ')[-1].strip()
if len(post_index) > 5:
post_index = "1"
if post_index.isdigit():
curr_index = int(post_index)
if curr_index > 0 and box_json:
@ -2015,6 +2029,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
curr_index = 0
if ' ' in command_str:
post_index = command_str.split(' ')[-1].strip()
if len(post_index) > 5:
post_index = "1"
if post_index.isdigit():
curr_index = int(post_index)
if curr_index > 0 and box_json:
@ -2046,6 +2062,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
curr_index = 0
if ' ' in command_str:
post_index = command_str.split(' ')[-1].strip()
if len(post_index) > 5:
post_index = "1"
if post_index.isdigit():
curr_index = int(post_index)
if curr_index > 0 and box_json:
@ -2082,6 +2100,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
curr_index = 0
if ' ' in command_str:
post_index = command_str.split(' ')[-1].strip()
if len(post_index) > 5:
post_index = "1"
if post_index.isdigit():
curr_index = int(post_index)
else:
@ -2128,6 +2148,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
curr_index = 0
if ' ' in command_str:
post_index = command_str.split(' ')[-1].strip()
if len(post_index) > 5:
post_index = "1"
if post_index.isdigit():
curr_index = int(post_index)
if curr_index > 0 and box_json:
@ -2160,6 +2182,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
curr_index = 0
if ' ' in command_str:
post_index = command_str.split(' ')[-1].strip()
if len(post_index) > 5:
post_index = "1"
if post_index.isdigit():
curr_index = int(post_index)
if curr_index > 0 and box_json:
@ -2203,6 +2227,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
curr_index = 0
if ' ' in command_str:
post_index = command_str.split(' ')[-1].strip()
if len(post_index) > 5:
post_index = "1"
if post_index.isdigit():
curr_index = int(post_index)
if curr_index > 0 and box_json:
@ -2236,6 +2262,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
curr_page = 1
if ' ' in command_str:
page_num = command_str.split(' ')[-1].strip()
if len(page_num) > 5:
page_num = "1"
if page_num.isdigit():
curr_page = int(page_num)
follow_requests_json = \
@ -2255,6 +2283,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
curr_page = 1
if ' ' in command_str:
page_num = command_str.split(' ')[-1].strip()
if len(page_num) > 5:
page_num = "1"
if page_num.isdigit():
curr_page = int(page_num)
following_json = \
@ -2275,6 +2305,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
curr_page = 1
if ' ' in command_str:
page_num = command_str.split(' ')[-1].strip()
if len(page_num) > 5:
page_num = "1"
if page_num.isdigit():
curr_page = int(page_num)
followers_json = \
@ -2484,6 +2516,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
curr_index = 0
if ' ' in command_str:
post_index = command_str.split(' ')[-1].strip()
if len(post_index) > 5:
post_index = "1"
if post_index.isdigit():
curr_index = int(post_index)
if curr_index > 0 and box_json:
@ -2555,6 +2589,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
curr_index = 0
if ' ' in command_str:
post_index = command_str.split(' ')[-1].strip()
if len(post_index) > 5:
post_index = "1"
if post_index.isdigit():
curr_index = int(post_index)
if curr_index > 0 and box_json:

View File

@ -453,6 +453,8 @@ def get_following_feed(base_dir: str, domain: str, port: int, path: str,
page_number = None
if '?page=' in path:
page_number = path.split('?page=')[1]
if len(page_number) > 5:
page_number = "1"
if page_number == 'true' or not authorized:
page_number = 1
else:

View File

@ -986,6 +986,8 @@ def person_box_json(recent_posts_cache: {},
page_number = None
if '?page=' in path:
page_number = path.split('?page=')[1]
if len(page_number) > 5:
page_number = 1
if page_number == 'true':
page_number = 1
else:

View File

@ -462,6 +462,8 @@ def get_shares_feed_for_person(base_dir: str,
page_number = None
if '?page=' in path:
page_number = path.split('?page=')[1]
if len(page_number) > 5:
page_number = 1
if page_number == 'true':
page_number = 1
else:

View File

@ -341,16 +341,19 @@ def html_calendar(person_cache: {}, translate: {},
if '=' in part:
if part.split('=')[0] == 'year':
num_str = part.split('=')[1]
if num_str.isdigit():
year = int(num_str)
if len(num_str) <= 5:
if num_str.isdigit():
year = int(num_str)
elif part.split('=')[0] == 'month':
num_str = part.split('=')[1]
if num_str.isdigit():
month_number = int(num_str)
if len(num_str) <= 3:
if num_str.isdigit():
month_number = int(num_str)
elif part.split('=')[0] == 'day':
num_str = part.split('=')[1]
if num_str.isdigit():
day_number = int(num_str)
if len(num_str) <= 3:
if num_str.isdigit():
day_number = int(num_str)
elif part.split('=')[0] == 'ical':
bool_str = part.split('=')[1]
if bool_str.lower().startswith('t'):