@@ -198,17 +198,19 @@ function isValidVersionField(value: unknown, isValidType: (v: unknown) => boolea
198198// `version`/`version_normalized` via .startsWith()/.split()/.endsWith()
199199// (isPackagistDevVersion/isPackagistPrerelease), `homepage` via blankToNull's .trim(),
200200// `license` as the text[] written to versions.licenses, `time` as the timestamptz
201- // written to versions.published_at. `require`/`require-dev` are already guarded at
202- // their own call site (extractVersionDependencies checks typeof before Object.entries)
203- // so aren't re-validated here.
201+ // written to versions.published_at — checking it's merely a string isn't enough, since
202+ // a non-date string like "not-a-date" would still be typeof 'string' but throw at the
203+ // v.pub::timestamptz SQL cast, deep past this guard. `require`/`require-dev` are already
204+ // guarded at their own call site (extractVersionDependencies checks typeof before
205+ // Object.entries) so aren't re-validated here.
204206function isValidMinifiedVersion ( v : unknown ) : boolean {
205207 if ( typeof v !== 'object' || v === null ) return false
206208 const entry = v as Record < string , unknown >
207209 return (
208210 typeof entry . version === 'string' &&
209211 isValidVersionField ( entry . version_normalized , ( x ) => typeof x === 'string' ) &&
210212 isValidVersionField ( entry . homepage , ( x ) => typeof x === 'string' ) &&
211- isValidVersionField ( entry . time , ( x ) => typeof x === 'string' ) &&
213+ isValidVersionField ( entry . time , ( x ) => typeof x === 'string' && ! isNaN ( Date . parse ( x ) ) ) &&
212214 isValidVersionField (
213215 entry . license ,
214216 ( x ) => Array . isArray ( x ) && x . every ( ( l ) => typeof l === 'string' ) ,
0 commit comments