Terminplaner: Einstellungen, URL-Host einschraenken und unsichtbare Formatzeichen entfernen
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9cacd5bd3b
commit
759be69250
2 files changed
+97
-11
No files matched your search
@@ -231,6 +231,72 @@ test('URLs: nur https, kein javascript:, keine Zugangsdaten, hoechstens 300 Zeic
|
||||
}
|
||||
})
|
||||
|
||||
test('URLs: nur ASCII-Hostnamen (Punycode), Anfuehrungszeichen/Apostroph/Backtick im Host abgelehnt', () => {
|
||||
const mit = (feld, wert) => ({ ...basis(), betrieb: { name: 'X', email: 'a@b.de', [feld]: wert } })
|
||||
for (const feld of ['impressumUrl', 'datenschutzUrl', 'agbUrl', 'websiteUrl']) {
|
||||
for (const schlecht of [
|
||||
'https://exa"mple.com/', "https://a'b.de/", 'https://a`b.de/', "https://a'b.de/x'y", 'https://a<b.de/', 'https://a>b.de/',
|
||||
'https://a|b.de/', 'https://a^b.de/', 'https://-a.de/', 'https://a..de/', 'https://a.de./', 'https://[zz]/x',
|
||||
]) {
|
||||
assert.ok(fehlerVon(mit(feld, schlecht))[`betrieb.${feld}`], `${feld}: ${schlecht}`)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
test('URLs: Apostroph im Pfad wird als %27 gespeichert, Umlaut-Hosts als Punycode, IPv6 in Klammern', () => {
|
||||
const url = (wert) => gueltig({ ...basis(), betrieb: { name: 'X', email: 'a@b.de', impressumUrl: wert } }).betrieb.impressumUrl
|
||||
assert.equal(url("https://ab.de/x'y"), 'https://ab.de/x%27y')
|
||||
assert.equal(url("https://ab.de/?q='a'#f'g"), 'https://ab.de/?q=%27a%27#f%27g')
|
||||
assert.equal(url('https://Salon.DE/Impressum'), 'https://salon.de/Impressum')
|
||||
assert.equal(url('https://Bücher.de/Über'), 'https://xn--bcher-kva.de/%C3%9Cber')
|
||||
assert.equal(url('https://sub.salon-müller.de/impressum'), 'https://sub.xn--salon-mller-zhb.de/impressum')
|
||||
assert.equal(url('https://[::1]/x'), 'https://[::1]/x')
|
||||
for (const gespeichert of [url("https://ab.de/x'y\"z`w"), url('https://a.de/?q="x"<y>')]) {
|
||||
assert.ok(!/['"`<>]/.test(gespeichert), gespeichert)
|
||||
}
|
||||
// die 300 Zeichen gelten fuer die gespeicherte Schreibweise (%27 ist laenger als ')
|
||||
const apostrophe = "'".repeat(110)
|
||||
assert.ok(fehlerVon({ ...basis(), betrieb: { name: 'X', email: 'a@b.de', impressumUrl: `https://ab.de/${apostrophe}` } })['betrieb.impressumUrl'])
|
||||
assert.equal(url(`https://ab.de/${"'".repeat(80)}`).length, 'https://ab.de/'.length + 80 * 3)
|
||||
})
|
||||
|
||||
test('Unsichtbare Formatzeichen: Name nur daraus ist leer (Pflichtfeld), sonst werden sie entfernt', () => {
|
||||
const name = (wert) => ({ ...basis(), betrieb: { name: wert, email: 'a@b.de' } })
|
||||
for (const leer of ['\u200B', '\u200E', '\u200F', '\u2060', '\uFEFF', '\u061C', '\u200B\u200E \uFEFF', ' \u200B\u200D\u200C ', '\u200D', '\u200C\u200D']) {
|
||||
assert.ok(fehlerVon(name(leer))['betrieb.name'], JSON.stringify(leer))
|
||||
}
|
||||
assert.equal(gueltig(name('A\u200EB\u061CC\uFEFFD')).betrieb.name, 'ABCD')
|
||||
for (const zeichen of ['\u200B', '\u200E', '\u200F', '\u2060', '\uFEFF', '\u061C', '\u00AD', '\u2061', '\u206A']) {
|
||||
assert.equal(gueltig(name(`Sa${zeichen}lon`)).betrieb.name, 'Salon', JSON.stringify(zeichen))
|
||||
}
|
||||
// ZWJ (Emoji-Sequenzen) und ZWNJ (persische Schrift) innerhalb des Textes bleiben
|
||||
assert.equal(gueltig(name('\u{1F469}\u200D\u{1F469}\u200D\u{1F467} Salon')).betrieb.name, '\u{1F469}\u200D\u{1F469}\u200D\u{1F467} Salon')
|
||||
assert.equal(gueltig(name('می\u200Cخواهم')).betrieb.name, 'می\u200Cخواهم')
|
||||
// am Rand sind sie wertlos und fallen weg
|
||||
assert.equal(gueltig(name('\u200DSalon\u200C ')).betrieb.name, 'Salon')
|
||||
})
|
||||
|
||||
test('Unsichtbare Formatzeichen: auch Leistungs-/Ressourcennamen, Storno, E-Mail und URL', () => {
|
||||
const e = basis()
|
||||
e.ressourcen[0].name = '\u200B'
|
||||
e.leistungen[0].name = '\uFEFF\u200F'
|
||||
const f = fehlerVon(e)
|
||||
assert.ok(f['ressourcen.0.name'])
|
||||
assert.ok(f['leistungen.0.name'])
|
||||
|
||||
const ok = basis()
|
||||
ok.ressourcen[0].name = 'An\u200Bna'
|
||||
ok.leistungen[0].beschreibung = 'Mit\u200E\u2060 Waschen'
|
||||
ok.storno = { text: 'Zeile\u200B 1\n\u200EZeile 2' }
|
||||
ok.betrieb = { name: 'X', email: 'in\u200Bfo@sa\uFEFFlon.de', impressumUrl: 'https://sa\u200Blon.de/imp\u2060ressum' }
|
||||
const e2 = gueltig(ok)
|
||||
assert.equal(e2.ressourcen[0].name, 'Anna')
|
||||
assert.equal(e2.leistungen[0].beschreibung, 'Mit Waschen')
|
||||
assert.equal(e2.storno.text, 'Zeile 1\nZeile 2')
|
||||
assert.equal(e2.betrieb.email, 'info@salon.de')
|
||||
assert.equal(e2.betrieb.impressumUrl, 'https://salon.de/impressum')
|
||||
})
|
||||
|
||||
test('Farbe, Anrede, Bundesland werden geprueft', () => {
|
||||
assert.equal(gueltig({ ...basis(), farbe: '#AABBCC' }).farbe, '#aabbcc')
|
||||
for (const schlecht of ['red', '#abc', '#12345g', 'ffffff', 5]) assert.ok(fehlerVon({ ...basis(), farbe: schlecht }).farbe, String(schlecht))
|
||||
|
||||
Reference in new issue
Block a user