Runner: Analyse null erlaubt, Adresse optional (R10)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Sonnet 5.5 committed 2026-10-01 10:03:24 +00:00
1 parent 7de9f1aaa3
commit 18d37d1e01
4 files changed
+20 -4

No files matched your search

+2 -1
View File
@@ -52,7 +52,8 @@ export async function injectAnalytics(dir, analytics, { baseUrl, onLine, fs = no
const tag = scriptTag(analytics, baseUrl);
const p = analytics.privacy || {};
const template = await fs.readFile(TEMPLATE_URL, 'utf8');
const page = template.replace(/\{\{(company|address|email)\}\}/g, (_, k) => esc(p[k] ?? ''));
const withAddr = p.address ? template.replace(/\{\{#address\}\}|\{\{\/address\}\}/g, '') : template.replace(/\{\{#address\}\}[\s\S]*?\{\{\/address\}\}/g, '');
const page = withAddr.replace(/\{\{(company|address|email)\}\}/g, (_, k) => esc(p[k] ?? ''));
await fs.writeFile(join(dir, PAGE), page, 'utf8');
await fs.chmod(join(dir, PAGE), 0o644);
let n = 0;
@@ -17,7 +17,7 @@
<p class="entwurf"><strong>Vorläufiger Entwurf:</strong> Dieser Text wird vor der Veröffentlichung noch redaktionell und rechtlich überarbeitet.</p>
<h2>Verantwortlicher</h2>
<p>{{company}}<br>{{address}}<br>E-Mail: <a href="mailto:{{email}}">{{email}}</a></p>
<p>{{company}}<br>{{#address}}{{address}}<br>{{/address}}E-Mail: <a href="mailto:{{email}}">{{email}}</a></p>
<h2>Zweck</h2>
<p>Wir möchten verstehen, wie diese Website genutzt wird, um sie zu verbessern (zum Beispiel welche Seiten gelesen werden und wo Besucher hängen bleiben). Es gibt keine Werbung und kein Profiling.</p>
+2 -1
View File
@@ -48,7 +48,7 @@ export function validateJob(body) {
}
}
let analytics;
if (body.analytics !== undefined) {
if (body.analytics !== undefined && body.analytics !== null) {
const a = body.analytics;
if (!a || typeof a !== 'object' || Array.isArray(a)) return { ok: false, error: 'Ungültige Analyse-Angaben' };
if (typeof a.siteKey !== 'string' || !RE_SITE_KEY.test(a.siteKey)) return { ok: false, error: 'Ungültiger Analyse-Schlüssel' };
@@ -59,6 +59,7 @@ export function validateJob(body) {
for (const [k, max] of [['company', 200], ['address', 300], ['email', 200]]) {
const v = pr[k];
// eslint-disable-next-line no-control-regex
if (k === 'address' && (v === undefined || v === '')) { privacy[k] = ''; continue; }
if (typeof v !== 'string' || !v.trim() || v.length > max || /[\x00-\x1f\x7f]/.test(v)) return { ok: false, error: `Ungültige Analyse-Datenschutzangabe: ${k}` };
privacy[k] = v;
}