diff options
author | Helmut Grohne <helmut@subdivi.de> | 2020-10-08 21:54:15 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2020-10-08 21:54:15 +0200 |
commit | 3ee1cd729ef5dd6f1fcce76c4c27d7f50823b124 (patch) | |
tree | 64a66a6c18b36db96f06d05875de9ca08e7fa48b | |
parent | aaae5693485ae850bfe2c9506f2586a9542641bf (diff) | |
download | crossqa-3ee1cd729ef5dd6f1fcce76c4c27d7f50823b124.tar.gz |
webapp.py: really fix schedule response
Also handle invalid form values with a BadRequest.
Fixes: bab219106d1b ("webapp.py: fix schedule response")
Fixes: a52d12012b1b ("webapp: add concept of "build architecture" to frontend")
-rw-r--r-- | webapp.py | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -278,8 +278,8 @@ schedule_template = """<!DOCTYPE html> <html> <body> <p>Scheduled a build of {{ request.form["source"]|e }} - {%- if request.form["archpair"] != "any_any" %} - for {{ request.form["archpair"]|archpair_format -}} + {%- if buildarch or hostarch %} + for {{ (buildarch|default("any"), hostarch|default("any"))|archpair_format -}} {%- endif %}. <p> </body> @@ -422,7 +422,10 @@ def show_log(filename): @app.route("/schedule", methods=["POST"]) def request_schedule(): source = flask.request.form["source"] - buildarch, hostarch = flask.request.form["archpair"].split("_") + try: + buildarch, hostarch = flask.request.form["archpair"].split("_") + except ValueError: + raise werkzeug.exceptions.BadRequest() if buildarch == "any": buildarch = None elif buildarch != "amd64": @@ -445,4 +448,5 @@ def request_schedule(): VALUES (:source, :buildarch, :hostarch, datetime('now'));""") conn.execute(query, source=source, buildarch=buildarch, hostarch=hostarch) - return flask.render_template_string(schedule_template) + return flask.render_template_string(schedule_template, buildarch=buildarch, + hostarch=hostarch) |