Sign-in look: the logo is handled as the white label handled it in 1.17.0 (owner, 2026-11-26)

A logo that showed on a site's login screen shows on the new screens: any picture Site settings holds,
an SVG included, as <img>; svgLogo: false refuses SVG (off by default); the list of allowed types is
gone. The look at the file only avoids a broken picture: a file that is gone (404 / 410) or is no picture
gives the name; anything else (no answer, a redirect, another status, over 512 KB) believes the upload.
Redirects are still never followed by the server, and the body is read with the 512 KB cap. A test
checks twelve kinds of logo that 1.17.0 shows. No plate stays the default. Docs, skills, changelog draft.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-26 22:14:50 +01:00
co-authored by Claude Fable 5.2
parent aef1efac73
commit 24ccc5dc8b
56 changed files with 177 additions and 114 deletions
+74 -34
View File
@@ -68,11 +68,11 @@ describe('whiteLabel.signIn: the option', () => {
logoField: 'brandLogo',
nameField: 'brandName',
settingsSlug: 'settings',
signIn: { accent: '#0B6E4F', allScreens: true, checkLogo: false, languages: false, logoPlate: true, svgLogo: true },
signIn: { accent: '#0B6E4F', allScreens: true, checkLogo: false, languages: false, logoPlate: true, svgLogo: false },
}),
).toEqual({
allScreens: true,
props: { accent: '#0B6E4F', checkLogo: false, imageField: 'brandLogo', inlineImages: false, languages: false, logoPlate: true, nameField: 'brandName', settingsSlug: 'settings', svgLogo: true },
props: { accent: '#0B6E4F', checkLogo: false, imageField: 'brandLogo', inlineImages: false, languages: false, logoPlate: true, nameField: 'brandName', settingsSlug: 'settings', svgLogo: false },
})
})
@@ -174,22 +174,25 @@ describe('what the public sign-in page may show', () => {
expect(long.endsWith('…')).toBe(true)
})
test('the logo: a bitmap by its type, an http(s) or site-relative address, never enlarged; SVG only when asked', () => {
test('the logo: any picture the upload holds, at an http(s) or site-relative address, never enlarged; SVG out only when asked', () => {
const png = (extra: Record<string, unknown>) => ({ mimeType: 'image/png', ...extra })
expect(signInLogo(png({ height: 100, url: '/api/media/file/logo.png', width: 400 }))).toEqual({ height: 60, src: '/api/media/file/logo.png', width: 240 })
expect(signInLogo({ height: 20, mimeType: 'image/webp', url: 'https://cdn.test/logo.webp', width: 60 })).toEqual({ height: 20, src: 'https://cdn.test/logo.webp', width: 60 })
expect(signInLogo(png({ url: '/logo.png' }))).toEqual({ src: '/logo.png' })
for (const mimeType of ['image/jpeg', 'image/png', 'image/webp', 'image/avif', 'image/gif', 'IMAGE/PNG']) {expect(signInLogo({ mimeType, url: '/l' })).toEqual({ src: '/l' })}
for (const mimeType of ['application/pdf', 'text/html', 'image/x-icon', 'image/tiff', 'video/mp4', undefined, 7]) {expect(signInLogo({ mimeType, url: '/l' })).toBeNull()}
// no list of types: what a browser shows as a picture is the browser's business; no stated type counts as before
for (const mimeType of ['image/jpeg', 'image/png', 'image/webp', 'image/avif', 'image/gif', 'IMAGE/PNG', 'image/x-icon', 'image/bmp', 'image/tiff', undefined, null, '']) {
expect(signInLogo({ mimeType, url: '/l' }), String(mimeType)).toEqual({ src: '/l' })
}
for (const mimeType of ['application/pdf', 'text/html', 'video/mp4']) {expect(signInLogo({ mimeType, url: '/l' })).toBeNull()}
for (const url of ['javascript:alert(1)', 'data:text/html,<script>1</script>', '//evil.test/x.png', 'file:///etc/passwd', '', ' ']) {
expect(signInLogo(png({ url }))).toBeNull()
}
expect(signInLogo('64f0…id-only')).toBeNull()
expect(signInLogo(null)).toBeNull()
const svg = { mimeType: 'image/svg+xml', url: '/api/media/file/logo.svg' }
expect(signInLogo(svg)).toBeNull()
expect(signInLogo(svg, { svgLogo: true })).toEqual({ src: svg.url })
expect(signInLogo(png({ url: '/api/media/file/renamed.SVG?v=2' }))).toBeNull()
expect(signInLogo(svg)).toEqual({ src: svg.url })
expect(signInLogo(svg, { svgLogo: false })).toBeNull()
expect(signInLogo(png({ url: '/api/media/file/renamed.SVG?v=2' }), { svgLogo: false })).toBeNull()
expect(fitLogo(1000, 100)).toEqual({ height: 24, width: 240 })
expect(fitLogo(0, 10)).toBeNull()
})
@@ -204,53 +207,90 @@ describe('what the public sign-in page may show', () => {
expect(signInLogo(logoDoc({}))).toEqual({ height: 60, src: '/full.png', width: 240 })
})
test('the file is looked at before it is printed: a deleted, broken, foreign or too large file gives the name', async () => {
test('the file is looked at before it is printed: a deleted file, or one that is no picture, gives the name', async () => {
const settings = { logo: { height: 160, mimeType: 'image/png', url: '/api/media/file/logo.png', width: 560 }, siteName: 'Acme' }
const brand = () => {
const brand = (look: Record<string, unknown> = {}) => {
forgetCheckedLogos()
return loadSignInBrand({ look: {}, payload: fakePayload(settings) })
return loadSignInBrand({ look, payload: fakePayload(settings) })
}
serve(PNG)
expect((await brand()).logo?.src).toBe(settings.logo.url)
vi.restoreAllMocks()
serve(null, { status: 404 })
expect(await brand()).toEqual({ name: 'Acme', logo: null })
vi.restoreAllMocks()
serve(new TextEncoder().encode('<svg xmlns="http://www.w3.org/2000/svg"><script>alert(1)</script></svg>')) // says image/png, is not
expect((await brand()).logo).toBeNull()
vi.restoreAllMocks()
serve(new TextEncoder().encode('<html>'), { headers: { 'content-type': 'text/html' } })
expect((await brand()).logo).toBeNull()
vi.restoreAllMocks()
serve(PNG, { headers: { 'content-length': String(600 * 1024), 'content-type': 'image/png' } })
expect((await brand()).logo).toBeNull()
vi.restoreAllMocks()
const answer = async (body: null | Uint8Array, init: ResponseInit, look?: Record<string, unknown>) => {
vi.restoreAllMocks()
serve(body, init)
return (await brand(look)).logo
}
const html = new TextEncoder().encode('<html>')
const svg = new TextEncoder().encode('<svg xmlns="http://www.w3.org/2000/svg"><script>alert(1)</script></svg>')
expect((await answer(PNG, {}))?.src).toBe(settings.logo.url)
// certainly not a picture at that address: the name
expect(await answer(null, { status: 404 })).toBeNull()
expect(await answer(null, { status: 410 })).toBeNull()
expect(await answer(html, { headers: { 'content-type': 'text/html' } })).toBeNull()
expect(await answer(new Uint8Array(0), {})).toBeNull()
// an SVG, also one the server calls a PNG: a picture in <img> (it cannot run script there) — unless refused
expect((await answer(svg, { headers: { 'content-type': 'image/svg+xml' } }))?.src).toBe(settings.logo.url)
expect((await answer(svg, {}))?.src).toBe(settings.logo.url)
expect(await answer(svg, { headers: { 'content-type': 'image/svg+xml' } }, { svgLogo: false })).toBeNull()
expect(await answer(svg, {}, { svgLogo: false })).toBeNull()
// a redirect is never followed by the server (it could point at an internal address): one request, to the
// logo's own address, asked not to follow; the upload document is believed and nothing is inlined from it
vi.restoreAllMocks()
const redirected = serve(null, { headers: { location: 'http://169.254.169.254/latest/meta-data/' }, status: 302 })
expect((await brand()).logo?.src).toBe(settings.logo.url)
expect(redirected).toHaveBeenCalledTimes(1)
expect(String(redirected.mock.calls[0][0])).toBe('https://site.test/api/media/file/logo.png')
expect((redirected.mock.calls[0][0] as URL).href).toBe('https://site.test/api/media/file/logo.png')
expect((redirected.mock.calls[0][1] as RequestInit).redirect).toBe('manual')
expect(await checkLogoFile('https://site.test/l.png', null)).toBe('unknown')
vi.restoreAllMocks()
// nothing answers (the site cannot reach its own address): the upload document is believed
vi.spyOn(globalThis, 'fetch').mockRejectedValue(new Error('ECONNREFUSED'))
expect((await brand()).logo?.src).toBe(settings.logo.url)
vi.restoreAllMocks()
// one look per address in ten minutes, and none with checkLogo: false
vi.restoreAllMocks()
const fetched = serve(PNG)
forgetCheckedLogos()
await loadSignInBrand({ look: {}, payload: fakePayload(settings) })
await loadSignInBrand({ look: {}, payload: fakePayload(settings) })
expect(fetched).toHaveBeenCalledTimes(1)
forgetCheckedLogos()
await loadSignInBrand({ look: { checkLogo: false }, payload: fakePayload(settings) })
await brand({ checkLogo: false })
expect(fetched).toHaveBeenCalledTimes(1)
expect(await checkLogoFile('ftp://site.test/logo.png', null)).toBe('bad')
expect(await checkLogoFile('/relative.png', null)).toBe('unknown')
})
// The owner's rule (2026-11-26): the logo is handled as IAPL's white label handled it on the login screen in
// 1.17.0 — `AdminLogo` printed `<img>` for whatever Site settings → Logo held. Nothing that showed there may
// be missing on the new screens.
test('a logo visible on the 1.17.0 login screen is visible after the upgrade', async () => {
const big = new Uint8Array(700 * 1024).fill(1)
big.set(PNG)
const svgBody = new TextEncoder().encode('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><rect width="10" height="10"/></svg>')
const ok = (body: Uint8Array, type: string) => () => Promise.resolve(new Response(body as never, { headers: { 'content-type': type } }))
const cases: [string, Record<string, unknown>, () => Promise<Response>][] = [
['an SVG logo', { mimeType: 'image/svg+xml', url: '/api/media/file/logo.svg' }, ok(svgBody, 'image/svg+xml')],
['a PNG logo', { height: 80, mimeType: 'image/png', url: '/api/media/file/logo.png', width: 300 }, ok(PNG, 'image/png')],
['a WebP logo on a CDN', { mimeType: 'image/webp', url: 'https://cdn.site.test/logo.webp' }, ok(new TextEncoder().encode('RIFF....WEBPVP8 '), 'image/webp')],
['an ICO or BMP logo', { mimeType: 'image/bmp', url: '/api/media/file/logo.bmp' }, ok(new TextEncoder().encode('BM......'), 'image/bmp')],
['an upload document without a type', { url: '/api/media/file/logo.png' }, ok(PNG, 'image/png')],
['a logo larger than 512 KB', { mimeType: 'image/png', url: '/api/media/file/big.png' }, ok(big, 'image/png')],
['a logo larger than 512 KB, length stated', { mimeType: 'image/png', url: '/api/media/file/big.png' }, () => Promise.resolve(new Response(PNG as never, { headers: { 'content-length': String(700 * 1024), 'content-type': 'image/png' } }))],
['a logo whose address redirects (a CDN)', { mimeType: 'image/png', url: '/api/media/file/logo.png' }, () => Promise.resolve(new Response(null, { headers: { location: 'https://cdn.site.test/logo.png' }, status: 302 }))],
['a site that cannot reach its own address', { mimeType: 'image/png', url: '/api/media/file/logo.png' }, () => Promise.reject(new Error('ECONNREFUSED'))],
['a firewall that refuses the server, not browsers', { mimeType: 'image/png', url: '/api/media/file/logo.png' }, () => Promise.resolve(new Response('denied', { status: 403 }))],
['a media server answering 500 to the server', { mimeType: 'image/png', url: '/api/media/file/logo.png' }, () => Promise.resolve(new Response('', { status: 503 }))],
['a media server that states no type', { mimeType: 'image/png', url: '/api/media/file/logo.png' }, () => Promise.resolve(new Response(PNG as never))],
]
for (const [name, logo, respond] of cases) {
vi.restoreAllMocks()
forgetCheckedLogos()
vi.spyOn(globalThis, 'fetch').mockImplementation(respond)
const payload = fakePayload({ logo, siteName: 'Acme' })
// 1.17.0: the plain logo component (no `signIn`) — unchanged code path
const before = (await AdminLogo({ payload })) as { props: { src?: string }; type: unknown }
expect(before.type, name).toBe('img')
expect(before.props.src, name).toBe(logo.url)
// after: the same address, in an <img> on the panel
expect((await loadSignInBrand({ look: {}, payload })).logo?.src, name).toBe(logo.url)
expect(await panel({ look: {}, payload }), name).toContain(`src="${String(logo.url)}"`)
}
})
test('markup in the name is text; the only links are the site, and the language endpoint', async () => {
const payload = fakePayload({ siteName: '<script>alert(1)</script> <a href="https://evil.test">reset</a> https://evil.test' })
const html = await panel({ i18n: { language: 'en', t: t as never }, look: {}, payload })