fix: close input normalization aliases

This commit is contained in:
2026-09-02 00:44:38 +03:00
parent 0a34f90bb9
commit 6428b5dcd6
4 changed files with 26 additions and 3 deletions

View File

@@ -6,7 +6,7 @@ const normalizeAssetBase = (base: string): string => {
if (
!base.startsWith('/') ||
base.startsWith('//') ||
/[\\%?#]/u.test(base) ||
/[\u0000-\u001f\u007f\\%?#]/u.test(base) ||
base.split('/').some((segment) => segment === '.' || segment === '..')
) {
throw new Error('Asset URL base must be a safe absolute path.');

View File

@@ -208,8 +208,7 @@ const siteConfigSchema = z.object({
canonicalUrl: httpUrl,
buildId: z.string().regex(/^[a-z0-9][a-z0-9._-]{0,127}$/, 'Build ID must be a safe immutable identifier.'),
}).strict().superRefine((site, context) => {
const url = new URL(site.canonicalUrl);
if (site.environment === 'preview' && (url.hostname !== 'portfolio.localhost' || url.port || url.pathname !== '/')) {
if (site.environment === 'preview' && site.canonicalUrl !== 'https://portfolio.localhost/') {
context.addIssue({ code: 'custom', message: 'Preview canonical URL must be exactly https://portfolio.localhost/.', path: ['canonicalUrl'] });
}
if (site.environment === 'production') {