normalizing request.full_path

remotes/1693045480750635534/spooky-22
Aevann1 2022-08-01 20:03:29 +02:00
parent db72908da6
commit e5a2980d1b
6 changed files with 14 additions and 13 deletions

View File

@ -96,7 +96,8 @@ def before_request():
g.webview = '; wv) ' in ua
g.inferior_browser = 'iphone' in ua or 'ipad' in ua or 'ipod' in ua or 'mac os' in ua or ' firefox/' in ua
request.path = request.path.rstrip("/")
request.path = request.path.rstrip('/')
request.full_path = request.full_path.rstrip('?').rstrip('/')
@app.after_request
def after_request(response):

View File

@ -37,8 +37,8 @@ WORDLE_COLOR_MAPPINGS = {-1: "🟥", 0: "🟨", 1: "🟩"}
@auth_desired
def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path.rstrip('?')}#context")
if v and request.path.startswith('/logged_out'): return redirect(request.full_path.replace('/logged_out','').rstrip('?') + '#context')
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}#context")
if v and request.path.startswith('/logged_out'): return redirect(request.full_path.replace('/logged_out','') + '#context')
try: cid = int(cid)
except: abort(404)

View File

@ -20,12 +20,12 @@ from files.helpers.awards import award_timers
def front_all(v, sub=None, subdomain=None):
if not v and not request.path.startswith('/logged_out'):
return redirect(f"/logged_out{request.full_path.rstrip('?')}")
return redirect(f"/logged_out{request.full_path}")
if v and v.is_banned and not v.unban_utc: return redirect('https://deuxrama.net')
if v and request.path.startswith('/logged_out'):
return redirect(request.full_path.replace('/logged_out','/').rstrip('?'))
return redirect(request.full_path.replace('/logged_out','/'))
if sub: sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none()

View File

@ -106,8 +106,8 @@ def submit_get(v, sub=None):
@auth_desired
def post_id(pid, anything=None, v=None, sub=None):
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path.rstrip('?')}")
if v and request.path.startswith('/logged_out'): return redirect(request.full_path.replace('/logged_out','').rstrip('?'))
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}")
if v and request.path.startswith('/logged_out'): return redirect(request.full_path.replace('/logged_out',''))
try: pid = int(pid)
except Exception as e: pass

View File

@ -59,8 +59,8 @@ def marsey_list():
@app.get('/logged_out/sidebar')
@auth_desired
def sidebar(v):
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path.rstrip('?')}")
if v and request.path.startswith('/logged_out'): return redirect(request.full_path.replace('/logged_out','').rstrip('?'))
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}")
if v and request.path.startswith('/logged_out'): return redirect(request.full_path.replace('/logged_out',''))
return render_template('sidebar.html', v=v)

View File

@ -908,10 +908,10 @@ def visitors(v):
def u_username(username, v=None):
if not v and not request.path.startswith('/logged_out'):
return redirect(f"/logged_out{request.full_path.rstrip('?')}")
return redirect(f"/logged_out{request.full_path}")
if v and request.path.startswith('/logged_out'):
return redirect(request.full_path.replace('/logged_out','').rstrip('?'))
return redirect(request.full_path.replace('/logged_out',''))
u = get_user(username, v=v, rendered=True)
@ -1020,10 +1020,10 @@ def u_username(username, v=None):
def u_username_comments(username, v=None):
if not v and not request.path.startswith('/logged_out'):
return redirect(f"/logged_out{request.full_path.rstrip('?')}")
return redirect(f"/logged_out{request.full_path}")
if v and request.path.startswith('/logged_out'):
return redirect(request.full_path.replace('/logged_out','').rstrip('?'))
return redirect(request.full_path.replace('/logged_out',''))
user = get_user(username, v=v, rendered=True)