Compare commits

2 Commits
Author SHA1 Message Date
clawbot 96ee54c8d6 Refuse a fit=outside size whose output exceeds the maximum (closes #257)
check / check (push) Failing after 6m42s
fit=outside scales the source to cover the requested size, and the side
scaled past it was held to no maximum: 1x8192?fit=outside of a 3000x600
source was resized to 40960x8192 and encoded. resize now refuses such an
output with ErrOutputTooLarge before resizing, so both image routes answer
it 400 with the error a size with one side 0 already gets. The other fit
modes make the requested size or one within it. README.md and TODO.md
say so.

Model: opus-5-5
2026-10-13 07:52:48 +00:00
clawbot 24ed6b7c58 Test that fit=outside is refused when its output exceeds the maximum
check / check (push) Failing after 3m23s
fit=outside scales the source to cover the requested size, and the side
that comes out past it is held to no maximum: 1x8192?fit=outside of a
3000x600 source makes a 40960x8192 output. The new tests expect such a
size to be refused with ErrOutputTooLarge, answered 400 on both image
routes, for the width and for the height, and a fit=outside output of at
most 8192 on each side to be made as before.

Model: opus-5-5
2026-10-13 07:49:08 +00:00
+8 -14
View File
@@ -19,17 +19,11 @@ import (
func TestImageProxyRefusesFitOutsideAboveMaximum(t *testing.T) { func TestImageProxyRefusesFitOutsideAboveMaximum(t *testing.T) {
t.Parallel() t.Parallel()
// The upstream paths of the sources // The sources, by their upstream paths
const (
widePath = "/wide.png"
rowPath = "/row.png"
columnPath = "/column.png"
)
sources := map[string][]byte{ sources := map[string][]byte{
widePath: encodeTestPNG(t, 3000, 600), "/wide.png": encodeTestPNG(t, 3000, 600),
rowPath: encodeTestPNG(t, 8192, 1), "/row.png": encodeTestPNG(t, 8192, 1),
columnPath: encodeTestPNG(t, 1, 8192), "/column.png": encodeTestPNG(t, 1, 8192),
} }
upstream := httptest.NewServer(http.HandlerFunc( upstream := httptest.NewServer(http.HandlerFunc(
@@ -52,10 +46,10 @@ func TestImageProxyRefusesFitOutsideAboveMaximum(t *testing.T) {
// wantWidth and wantHeight are the served image's, 0 for a refusal // wantWidth and wantHeight are the served image's, 0 for a refusal
wantWidth, wantHeight int wantWidth, wantHeight int
}{ }{
{widePath, 1, 8192, 0, 0}, {"/wide.png", 1, 8192, 0, 0},
{rowPath, 1, 8192, 0, 0}, {"/row.png", 1, 8192, 0, 0},
{columnPath, 8192, 1, 0, 0}, {"/column.png", 8192, 1, 0, 0},
{widePath, 1, 1200, 6000, 1200}, {"/wide.png", 1, 1200, 6000, 1200},
} }
for _, tt := range tests { for _, tt := range tests {