Skip to content

Commit

Permalink
Fix animated png bypass from Image Optimization API (#35120)
Browse files Browse the repository at this point in the history
- Fixes #34807
- Related commit qzb/is-animated@69dad3c

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
  • Loading branch information
styfle and ijjk committed Mar 7, 2022
1 parent 0e5e888 commit b25f7f8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -116,7 +116,7 @@
"gzip-size": "5.1.1",
"html-validator": "5.1.18",
"image-size": "0.9.3",
"is-animated": "2.0.0",
"is-animated": "2.0.2",
"isomorphic-unfetch": "3.0.0",
"jest": "27.0.6",
"ky": "0.19.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/next/compiled/is-animated/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions test/integration/image-optimizer/test/util.js
Expand Up @@ -189,6 +189,22 @@ export function runTests(ctx) {
expect(isAnimated(await res.buffer())).toBe(true)
})

it('should maintain animated png 2', async () => {
const query = { w: ctx.w, q: 90, url: '/animated2.png' }
const res = await fetchViaHTTP(ctx.appPort, '/_next/image', query, {})
expect(res.status).toBe(200)
expect(res.headers.get('content-type')).toContain('image/png')
expect(res.headers.get('Cache-Control')).toBe(
`public, max-age=0, must-revalidate`
)
expect(res.headers.get('Vary')).toBe('Accept')
expect(res.headers.get('etag')).toBeTruthy()
expect(res.headers.get('Content-Disposition')).toBe(
`inline; filename="animated2.png"`
)
expect(isAnimated(await res.buffer())).toBe(true)
})

it('should maintain animated webp', async () => {
const query = { w: ctx.w, q: 90, url: '/animated.webp' }
const res = await fetchViaHTTP(ctx.appPort, '/_next/image', query, {})
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -12056,10 +12056,10 @@ is-alphanumerical@^1.0.0:
is-alphabetical "^1.0.0"
is-decimal "^1.0.0"

is-animated@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-animated/-/is-animated-2.0.0.tgz#ffb1f180ff10782b8442dcb0955b5fc915e1a111"
integrity sha512-ZsfhGnSRUjto9owW5WpaDL7z/03H77Ny9JgP/BSyOQ/mAPAKNbdX30WNYbg2R5NhvT5VqKs2KL38znj5OG8tDg==
is-animated@2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/is-animated/-/is-animated-2.0.2.tgz#579a5d30b0d28c71bfef9dc46ebec969269461ab"
integrity sha512-+Hi3UdXHV/3ZgxdO9Ik45ciNhDlYrDOIdGz7Cj7ybddWnYBi4kwBuGMn79Xa2Js4VldgX5e3943Djsr/KYSPbA==

is-arguments@^1.0.4:
version "1.0.4"
Expand Down

0 comments on commit b25f7f8

Please sign in to comment.