Consent (GDPR)
- Withdrawing consent now deletes GA/Meta/Ads/Clarity/LinkedIn/TikTok/Hotjar
cookies (prefix patterns) on the host AND parent domains — previously only
the locale cookie was removed and _ga & co. stayed. Projects extend the list
via <ConsentProvider cookieMap>, merged with the defaults.
- Cookie Settings → Policy version: raising it asks every visitor again.
- <CookieBanner equalChoice>: Reject styled like Accept (UODO/EDPB), opt-in.
- Opt-in consent log (ipalKit({ consentLog: true }) + logEndpoint): random id,
choices, version, time — no IP/UA; admin-only collection, retention purge.
- Cookie Settings → Cookies + getCookieTable + unstyled <CookieTable> (/rsc).
- Consent cookie gets Secure on HTTPS; consent id stored with the decision.
- ipal-consent-check: cookie-scan.mjs (before/after consent, known-tool
catalog PL/EN, flags non-necessary cookies set before consent) and
import-cookies.ts into the panel (idempotent, keeps editor edits).
Forms
- Server-side type checks per field from the panel definition: email = one
address (blocks "a@x, b@y" recipient injection into {{email}} confirmations
and CR/LF header injection), select/radio only configured options, numbers,
booleans; objects/arrays rejected; control and bidi characters stripped.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
68 lines
2.8 KiB
TypeScript
68 lines
2.8 KiB
TypeScript
import { describe, expect, test } from 'vitest'
|
||
|
||
import { validateSubmission } from '../src/modules/forms/validateSubmission.js'
|
||
import { fakePayload } from './helpers.js'
|
||
|
||
const forms = {
|
||
f: {
|
||
fields: [
|
||
{ name: 'name', blockType: 'text' },
|
||
{ name: 'email', blockType: 'email' },
|
||
{ name: 'topic', blockType: 'select', options: [{ value: 'offer' }, { value: 'support' }] },
|
||
{ name: 'count', blockType: 'number' },
|
||
{ name: 'message', blockType: 'textarea' },
|
||
{ name: 'agree', blockType: 'checkbox' },
|
||
],
|
||
},
|
||
}
|
||
const { payload } = fakePayload({ forms })
|
||
const check = (data: Record<string, unknown>) => validateSubmission(payload, 'f', data)
|
||
|
||
describe('form validation — injection and abuse', () => {
|
||
test.each([
|
||
['[email protected], [email protected]'],
|
||
['[email protected];[email protected]'],
|
||
['[email protected]\r\nBcc: [email protected]'],
|
||
['Name <[email protected]>'],
|
||
['not-an-email'],
|
||
[`${'a'.repeat(250)}@x.pl`],
|
||
])('email %j is rejected — no extra recipients or headers', async (email) => {
|
||
expect(await check({ email })).toMatchObject({ field: 'email', kind: 'invalid_format', ok: false })
|
||
})
|
||
|
||
test('a valid email is trimmed and kept', async () => {
|
||
expect(await check({ email: ' [email protected] ' })).toMatchObject({
|
||
cleaned: { email: '[email protected]' },
|
||
ok: true,
|
||
})
|
||
})
|
||
|
||
test('select accepts only values configured in the panel', async () => {
|
||
expect(await check({ topic: 'offer' })).toMatchObject({ ok: true })
|
||
expect(await check({ topic: '<script>alert(1)</script>' })).toMatchObject({ field: 'topic', kind: 'invalid_format' })
|
||
})
|
||
|
||
test('objects, arrays and wrong types are rejected', async () => {
|
||
expect(await check({ name: { $gt: '' } })).toMatchObject({ field: 'name', kind: 'invalid_format' })
|
||
expect(await check({ message: ['a', 'b'] })).toMatchObject({ field: 'message', kind: 'invalid_format' })
|
||
expect(await check({ count: '12abc' })).toMatchObject({ field: 'count', kind: 'invalid_format' })
|
||
expect(await check({ agree: 'true' })).toMatchObject({ field: 'agree', kind: 'invalid_format' })
|
||
})
|
||
|
||
test('control and bidi characters are stripped; single-line text loses line breaks', async () => {
|
||
const res = await check({ name: 'Jan\r\nKowalski\u0007', message: 'Dzień\u0000 dobry\nlinia 2' })
|
||
expect(res).toMatchObject({ cleaned: { name: 'Jan Kowalski', message: 'Dzień dobry\nlinia 2' }, ok: true })
|
||
})
|
||
|
||
test('HTML is stored as text (the renderer and e-mails escape it)', async () => {
|
||
expect(await check({ message: '<img src=x onerror=alert(1)>' })).toMatchObject({
|
||
cleaned: { message: '<img src=x onerror=alert(1)>' },
|
||
ok: true,
|
||
})
|
||
})
|
||
|
||
test('numbers are normalized', async () => {
|
||
expect(await check({ count: ' 42 ' })).toMatchObject({ cleaned: { count: 42 }, ok: true })
|
||
})
|
||
})
|