http: Handle wrong build number on details route.

The request "/build/2465370mdb%22fx'ggx/details" causes a select query on the
whole Builds table, because failed "string->number" conversion is not handled.

* src/cuirass/http.scm (url-handler): Handle erroneous id -> number conversion
on "/build/id/details" route.
This commit is contained in:
Mathieu Othacehe 2020-08-02 18:30:37 +02:00
parent 769682924c
commit ce89a40ed8
No known key found for this signature in database
GPG Key ID: 8354763531769CA6
1 changed files with 3 additions and 2 deletions

View File

@ -363,8 +363,9 @@ Hydra format."
(respond-json (object->json-string hydra-build))
(respond-build-not-found id))))
(('GET "build" build-id "details")
(let ((build (db-get-build (string->number build-id)))
(products (db-get-build-products build-id)))
(let* ((id (string->number build-id))
(build (and id (db-get-build id)))
(products (and build (db-get-build-products build-id))))
(if build
(respond-html
(html-page (string-append "Build " build-id)