Sign-in look: the logo check never follows a redirect; the review pictures stay out of the package

checkLogoFile asks only the address the upload has (redirect: 'manual'); a redirecting logo counts as
unknown, so the server fetches nothing at an internal address. docs/dev/login-page/*.png is excluded
in package.json files (npm pack --dry-run: none of them packed).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-26 21:44:39 +01:00
co-authored by Claude Fable 5.2
parent 939ab679c7
commit 562bf5388d
4 changed files with 16 additions and 2 deletions
+5 -1
View File
@@ -132,6 +132,9 @@ export type LogoCheck = 'bad' | 'unknown' | { bytes: Buffer; type: string }
* - `'bad'` when the server ANSWERS and it is no such picture: 404, another type, too large, broken bytes;
* - `'unknown'` when nothing answers (the site cannot reach its own address from inside its container, a
* timeout): the upload document is then believed, so a network quirk never takes the logo away.
* A redirect is NEVER followed: the server asks only the address the upload itself has, so a logo address
* that answers "go to http://169.254.169.254/…" (or any internal host) makes the server fetch nothing there.
* Such a logo counts as `'unknown'`: the browser may follow it, the server does not.
*/
export async function checkLogoFile(url: string, base: null | string | undefined, allowSvg = false): Promise<LogoCheck> {
let target: URL
@@ -143,11 +146,12 @@ export async function checkLogoFile(url: string, base: null | string | undefined
if (target.protocol !== 'http:' && target.protocol !== 'https:') {return 'bad'}
let res: Response
try {
res = await fetch(target, { credentials: 'omit', redirect: 'follow', signal: AbortSignal.timeout(4000) })
res = await fetch(target, { credentials: 'omit', redirect: 'manual', signal: AbortSignal.timeout(4000) })
} catch {
return 'unknown'
}
try {
if ((res.status >= 300 && res.status < 400) || res.type === 'opaqueredirect') {return 'unknown'}
if (!res.ok) {return res.status >= 500 ? 'unknown' : 'bad'}
const declared = Number(res.headers.get('content-length'))
if (Number.isFinite(declared) && declared > PUBLIC_IMAGE_MAX_BYTES) {return 'bad'}