1
0
Fork 0
mirror of https://github.com/Lynnesbian/FediBooks/ synced 2024-11-25 08:38:59 +00:00

remove leading/trailing whitespace from account @ in bot accounts add page

This commit is contained in:
Lynne Megido 2020-04-11 17:17:39 +10:00
parent 5def1f2fe6
commit 8469b73c3c
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90

View file

@ -5,13 +5,15 @@ import re, json
def bot_accounts_add(mysql, cfg): def bot_accounts_add(mysql, cfg):
if request.method == 'POST': if request.method == 'POST':
# remove leading/trailing whitespace
session['handle'] = request.form['account'].rstrip().lstrip()
if session['step'] == 1: if session['step'] == 1:
if request.form['account'] == session['bot']: if session['handle'] == session['bot']:
error = "Bots cannot learn from themselves." error = "Bots cannot learn from themselves."
return render_template("bot/accounts_add.html", error = error) return render_template("bot/accounts_add.html", error = error)
# look up user # look up user
handle_list = request.form['account'].split('@') handle_list = session['handle'].split('@')
if len(handle_list) != 3: if len(handle_list) != 3:
# not formatted correctly # not formatted correctly
error = "Incorrectly formatted handle." error = "Incorrectly formatted handle."
@ -19,7 +21,6 @@ def bot_accounts_add(mysql, cfg):
session['username'] = handle_list[1] session['username'] = handle_list[1]
session['instance'] = handle_list[2] session['instance'] = handle_list[2]
session['handle'] = request.form['account']
if session['instance'] in json.load(open("blacklist.json")): if session['instance'] in json.load(open("blacklist.json")):
session['error'] = "Learning from accounts on this instance is not allowed." session['error'] = "Learning from accounts on this instance is not allowed."