Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My Alliance input validation, now with less false positives! #33

Merged
merged 1 commit into from Oct 11, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions screeps_loan/routes/my_alliance.py
Expand Up @@ -61,10 +61,19 @@ def update_my_alliance_charter():

@app.route('/my/updateprofile', methods=["POST"])
def update_my_alliance_profile():
fullname = re.sub(r'([^\s\w]|_)+', '', request.form['fullname'])
shortname = re.sub(r'([^\s\w]|_)+', '', request.form['shortname'])
slack_channel = re.sub(r'([^\s\w]|_)+', '', request.form['slack_channel'])
color = re.sub(r'([^\s\w#])+', '', request.form['color'])

if re.match('^[\w|\s]+$', request.form['fullname']):
fullname = request.form['fullname']

if re.match('^\w+$', request.form['shortname']):
shortname = request.form['shortname']

if re.match('^\w+$', request.form['slack_channel']):
slack_channel = request.form['slack_channel']

if re.match('^[a-fA-F0-9#]+$', request.form['color']):
color = request.form['color']

my_id = session['my_id']
alliance = users_model.alliance_of_user(my_id)
alliances_model.update_all_alliances_info(alliance['shortname'], shortname, fullname, slack_channel, color)
Expand Down