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