Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98d23ad32e | ||
|
|
a3dd1aad4e |
@@ -35,8 +35,7 @@ exhaustion
|
|||||||
400 naming `q` and the value, instead of being served at the default
|
400 naming `q` and the value, instead of being served at the default
|
||||||
85; the route reads `q` with the generator's quality check
|
85; the route reads `q` with the generator's quality check
|
||||||
(`parseFormInt` with `minQuality` and `maxQuality`); only a `q` missing
|
(`parseFormInt` with `minQuality` and `maxQuality`); only a `q` missing
|
||||||
from the URL is still 85; a query string that cannot be decoded, such
|
from the URL is still 85; `README.md` states the range.
|
||||||
as `q=80%`, is a 400 showing it; `README.md` states the range.
|
|
||||||
- 2026-09-28 unknown `PIXA_` environment variables abort startup (closes
|
- 2026-09-28 unknown `PIXA_` environment variables abort startup (closes
|
||||||
#133): a variable whose name starts with `PIXA_` but is neither a
|
#133): a variable whose name starts with `PIXA_` but is neither a
|
||||||
setting's variable nor `PIXA_CONFIG_PATH` aborts startup naming it, as
|
setting's variable nor `PIXA_CONFIG_PATH` aborts startup naming it, as
|
||||||
|
|||||||
@@ -295,9 +295,8 @@ func TestHandleImage_InvalidFitMode_Returns400(t *testing.T) {
|
|||||||
|
|
||||||
// TestHandleImage_InvalidQuality_Returns400 verifies that the plain image
|
// TestHandleImage_InvalidQuality_Returns400 verifies that the plain image
|
||||||
// route answers a q that is not a whole number from 1 to 100, an empty one
|
// route answers a q that is not a whole number from 1 to 100, an empty one
|
||||||
// included, with 400 naming q and the value, and a query string that cannot
|
// included, with 400 naming q and the value, instead of serving the image at
|
||||||
// be decoded with 400 showing it, instead of serving the image at the default
|
// the default quality 85.
|
||||||
// quality 85.
|
|
||||||
func TestHandleImage_InvalidQuality_Returns400(t *testing.T) {
|
func TestHandleImage_InvalidQuality_Returns400(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@@ -309,12 +308,6 @@ func TestHandleImage_InvalidQuality_Returns400(t *testing.T) {
|
|||||||
{"q=101", `invalid q: must be from 1 to 100, got "101"`},
|
{"q=101", `invalid q: must be from 1 to 100, got "101"`},
|
||||||
{"q=", `invalid q: not a number, got ""`},
|
{"q=", `invalid q: not a number, got ""`},
|
||||||
{"q=&q=500", `invalid q: not a number, got ""`},
|
{"q=&q=500", `invalid q: not a number, got ""`},
|
||||||
{"q=80%", `invalid query string "q=80%": invalid URL escape "%"`},
|
|
||||||
{
|
|
||||||
"q=50;fit=contain",
|
|
||||||
`invalid query string "q=50;fit=contain": ` +
|
|
||||||
`invalid semicolon separator in query`,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -92,17 +91,8 @@ func (s *Handlers) parseImageRequest(
|
|||||||
// Convert to ImageRequest
|
// Convert to ImageRequest
|
||||||
req := parsed.ToImageRequest()
|
req := parsed.ToImageRequest()
|
||||||
|
|
||||||
// Parse signature params from query string. r.URL.Query() would silently
|
// Parse signature params from query string
|
||||||
// drop a pair it cannot decode, such as q=80%, so that q would be served
|
query := r.URL.Query()
|
||||||
// at 85; a query string that cannot be decoded is refused instead.
|
|
||||||
query, err := url.ParseQuery(r.URL.RawQuery)
|
|
||||||
if err != nil {
|
|
||||||
s.respondError(w, fmt.Sprintf("invalid query string %q: %v",
|
|
||||||
r.URL.RawQuery, err), http.StatusBadRequest)
|
|
||||||
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Signature = query.Get("sig")
|
req.Signature = query.Get("sig")
|
||||||
|
|
||||||
if expStr := query.Get("exp"); expStr != "" {
|
if expStr := query.Get("exp"); expStr != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user