fix: correzioni della revisione finale (testi, visuale, brief, codice)
- testi: «lo Studio» uniforme, «Centro autorizzato CAF», ripetizioni tolte nei servizi e in «Lo studio», valori senza superlativi, meta corrette, testo della mappa di §10.2, numeri e indirizzi con spazi non separabili - visuale: breadcrumb, anello della banda CTA, card dei professionisti, pager e sidebar dei servizi su mobile, pagine legali a colonna singola, pulsante e-mail su una riga, card sedi allineate - dati: fatti della sede di Asti da studio.ts/testi.ts, sede.telefono - 404 e conferma senza canonical; avviso mappa senza JavaScript - controlli: CSP per direttive (endpoint), anno da SOURCE_DATE_EPOCH, URL del sito controllati sulla build locale, import file:// e tar da stdin per Windows, .gitattributes, porta libera corretta - modulo: pattern del telefono valido, avviso visibile, Esc sul sottomenu aperto al passaggio del mouse; contact.php con -f, senza mbstring obbligatorio, fuso Europe/Rome - release: note --shell-safe, ripiego REST automatico, RELEASE_TOKEN; deploy di esempio senza esclusione di contact.php; nginx /privacy/ - DECISIONS D-040–D-044, TODO C4 e riferimenti di riga aggiornati Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016zJ9ZWGKvoKoxYwbmnRKdJ
This commit is contained in:
51 files changed
+560
-185
No files matched your search
@@ -8,14 +8,18 @@
|
||||
*/
|
||||
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
||||
import { join, resolve } from 'node:path';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { DomUtils, parseDocument } from 'htmlparser2';
|
||||
import { fileToPath, listHtmlFiles, readSitemapPaths } from './lib/pages.mjs';
|
||||
import { root } from './lib/preview-server.mjs';
|
||||
|
||||
const dist = resolve(root, 'dist');
|
||||
const { abilitazioni, professionisti, studio, contactForm } = await import(
|
||||
resolve(root, 'src/data/studio.ts')
|
||||
);
|
||||
// I moduli TypeScript del sito sono importati direttamente (type stripping di Node), con URL
|
||||
// file:// perché su Windows un percorso assoluto non è un URL valido per import().
|
||||
const importSrc = (path) => import(pathToFileURL(resolve(root, path)).href);
|
||||
const { abilitazioni, professionisti, studio, contactForm } = await importSrc('src/data/studio.ts');
|
||||
// stesso anno del footer: SOURCE_DATE_EPOCH, se impostata, altrimenti l'anno corrente
|
||||
const { buildYear } = await importSrc('src/lib/build.ts');
|
||||
|
||||
const SITE = (process.env.SITE_URL || 'https://www.grassoezio.it').replace(/\/+$/, '');
|
||||
const PIVA = `P.IVA ${studio.partitaIva}`;
|
||||
@@ -199,7 +203,7 @@ const COMMERCIALISTA_OK =
|
||||
/giulia|odcec|(ordine|consiglio nazionale) dei dottori commercialisti|\bocc\b|organismo di composizione della crisi/i;
|
||||
const titles = new Map();
|
||||
const descriptions = new Map();
|
||||
const year = String(new Date().getFullYear());
|
||||
const year = String(buildYear);
|
||||
|
||||
for (const page of pages) {
|
||||
const { doc, file, path, html } = page;
|
||||
@@ -242,16 +246,21 @@ for (const page of pages) {
|
||||
if (descriptions.has(desc)) fail(where, `descrizione duplicata di ${descriptions.get(desc)}`);
|
||||
descriptions.set(desc, path);
|
||||
|
||||
if (path !== '/404.html') {
|
||||
const canonical = findOne(
|
||||
(n) => n.name === 'link' && attr(n, 'rel') === 'canonical',
|
||||
doc.children,
|
||||
);
|
||||
// canonical e og:url solo per le pagine indicizzabili (404 e conferma del modulo: nessuno)
|
||||
const canonical = findOne(
|
||||
(n) => n.name === 'link' && attr(n, 'rel') === 'canonical',
|
||||
doc.children,
|
||||
);
|
||||
const ogUrl = findOne((n) => n.name === 'meta' && attr(n, 'property') === 'og:url', doc.children);
|
||||
if (NOINDEX_PAGES.includes(path)) {
|
||||
check(!canonical && !ogUrl, where, 'pagina noindex con canonical o og:url');
|
||||
} else {
|
||||
check(
|
||||
attr(canonical ?? {}, 'href') === `${SITE}${path}`,
|
||||
where,
|
||||
`canonical atteso ${SITE}${path}, trovato ${attr(canonical ?? {}, 'href')}`,
|
||||
);
|
||||
check(attr(ogUrl ?? {}, 'content') === `${SITE}${path}`, where, 'og:url diverso dal canonical');
|
||||
}
|
||||
|
||||
// un solo h1
|
||||
@@ -689,10 +698,6 @@ for (const [re, what] of [
|
||||
/RedirectMatch 301 \^\/privacy\/\?\$ \/privacy-policy\//,
|
||||
'redirect /privacy → /privacy-policy/',
|
||||
],
|
||||
[
|
||||
/Content-Security-Policy "default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; script-src 'self'; font-src 'self'; frame-src https:\/\/www\.google\.com; form-action 'self'; base-uri 'self'; frame-ancestors 'self'"/,
|
||||
'Content-Security-Policy di §9.4',
|
||||
],
|
||||
[/X-Content-Type-Options "nosniff"/, 'X-Content-Type-Options'],
|
||||
[/Referrer-Policy "strict-origin-when-cross-origin"/, 'Referrer-Policy'],
|
||||
[/Permissions-Policy/, 'Permissions-Policy'],
|
||||
@@ -703,6 +708,55 @@ for (const [re, what] of [
|
||||
check(re.test(htaccess), 'dist/.htaccess', `manca: ${what}`);
|
||||
}
|
||||
|
||||
// Content-Security-Policy di §9.4, confrontata per direttive. Con il modulo esterno
|
||||
// (`contactForm.mode = 'endpoint'`) form-action deve ammettere anche l'origine del fornitore.
|
||||
const EXPECTED_CSP = {
|
||||
'default-src': ["'self'"],
|
||||
'img-src': ["'self'", 'data:'],
|
||||
'style-src': ["'self'", "'unsafe-inline'"],
|
||||
'script-src': ["'self'"],
|
||||
'font-src': ["'self'"],
|
||||
'frame-src': ['https://www.google.com'],
|
||||
'form-action': ["'self'"],
|
||||
'base-uri': ["'self'"],
|
||||
'frame-ancestors': ["'self'"],
|
||||
};
|
||||
if (contactForm.mode === 'endpoint' && /^https:\/\//.test(contactForm.endpoint)) {
|
||||
EXPECTED_CSP['form-action'].push(new URL(contactForm.endpoint).origin);
|
||||
}
|
||||
/** Direttive della CSP in forma canonica (direttive e sorgenti in ordine alfabetico). */
|
||||
const canonicalCsp = (directives) =>
|
||||
JSON.stringify(
|
||||
Object.entries(directives)
|
||||
.map(([name, sources]) => [name, [...sources].sort()])
|
||||
.sort(([a], [b]) => a.localeCompare(b)),
|
||||
);
|
||||
const parseCsp = (value) =>
|
||||
Object.fromEntries(
|
||||
value
|
||||
.split(';')
|
||||
.map((d) => d.trim().split(/\s+/))
|
||||
.filter((d) => d[0])
|
||||
.map(([name, ...sources]) => [name, sources]),
|
||||
);
|
||||
const cspLines = [
|
||||
...htaccess.matchAll(/^\s*Header always set Content-Security-Policy "([^"]+)"/gm),
|
||||
];
|
||||
check(
|
||||
cspLines.length === 1,
|
||||
'dist/.htaccess',
|
||||
`attesa una sola Content-Security-Policy attiva, trovate ${cspLines.length}`,
|
||||
);
|
||||
if (cspLines.length === 1) {
|
||||
check(
|
||||
canonicalCsp(parseCsp(cspLines[0][1])) === canonicalCsp(EXPECTED_CSP),
|
||||
'dist/.htaccess',
|
||||
`Content-Security-Policy diversa da quella attesa (§9.4${
|
||||
contactForm.mode === 'endpoint' ? ' + origine del modulo esterno in form-action' : ''
|
||||
}): «${cspLines[0][1]}»`,
|
||||
);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ esito */
|
||||
|
||||
if (errors.length > 0) {
|
||||
|
||||
Reference in new issue
Block a user