ValidateQuery is the query-string half of the same rule ValidatePath applies to the path: reject a request whose DECODED query keys or values are not values the database can be asked about. WHY A TRANSPORT RULE HERE, when BUG-2782 said the query string would be validated at its points of use. That
(decorate func(http.Handler) http.Handler)
| 267 | // |
| 268 | // BUG-2784. |
| 269 | func ValidateQuery(decorate func(http.Handler) http.Handler) func(http.Handler) http.Handler { |
| 270 | var reject http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 271 | w.Header().Set("Content-Type", "application/json") |
| 272 | writeError(w, http.StatusBadRequest, "invalid_query", |
| 273 | "Request query string contains invalid UTF-8 or a NUL byte") |
| 274 | }) |
| 275 | if decorate != nil { |
| 276 | reject = decorate(reject) |
| 277 | } |
| 278 | return func(next http.Handler) http.Handler { |
| 279 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 280 | if !validQueryText(r.URL.RawQuery) { |
| 281 | reject.ServeHTTP(w, r) |
| 282 | return |
| 283 | } |
| 284 | next.ServeHTTP(w, r) |
| 285 | }) |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | // validQueryText reports whether every key and value a handler could read |
| 290 | // out of this raw query string is bindableText. |
no test coverage detected