From 3ee1cd729ef5dd6f1fcce76c4c27d7f50823b124 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Thu, 8 Oct 2020 21:54:15 +0200 Subject: 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") --- webapp.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'webapp.py') diff --git a/webapp.py b/webapp.py index 03d37b3..8cdd43a 100644 --- a/webapp.py +++ b/webapp.py @@ -278,8 +278,8 @@ schedule_template = """

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 %}.

@@ -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) -- cgit v1.2.3