]> git.scottworley.com Git - voter/blobdiff - src/main.rs
Release 0.3.0
[voter] / src / main.rs
index 1ec9d9c352d41d0d01e259cee2de52df43a70e22..92937e58ff6f9b73a313d554432f695083b99161 100644 (file)
@@ -275,6 +275,13 @@ fn record_vote(dir: &Path, request: &cgi::Request) -> Result<cgi::Response, cgi:
     {
         return Err(cgi::text_response(415, "Invalid vote"));
     }
+    let elim =
+        read_elim_list(dir).map_err(|_| cgi::text_response(503, "Couldn't read eliminations"))?;
+    if elim.contains(
+        std::str::from_utf8(&body[2..]).map_err(|_| cgi::text_response(415, "Vote not UTF-8"))?,
+    ) {
+        return Err(cgi::text_response(403, "Candidate eliminated"));
+    }
     write_vote(dir, get_voter(request)?, body)
         .map_err(|_| cgi::text_response(503, "Couldn't record vote"))?;
     Ok(cgi::text_response(200, "Vote recorded"))