Fix: HTML-Tags in Nachrichten-Vorschau strippen

This commit is contained in:
rene 2026-05-22 08:10:13 +02:00
parent 957c4a9707
commit 51c0fe58aa
2 changed files with 6 additions and 2 deletions

View file

@ -26,6 +26,10 @@
loading = false;
});
function stripHtml(html: string): string {
return html.replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim();
}
function toggleGruppe(id: string) {
fGruppeIds = fGruppeIds.includes(id)
? fGruppeIds.filter((g) => g !== id)
@ -116,7 +120,7 @@
</div>
<span class="karte-meta">{gruppenLabel(n.gruppe_ids ?? [])}</span>
{#if n.text}
<p class="karte-vorschau">{n.text.slice(0, 120)}{n.text.length > 120 ? '…' : ''}</p>
<p class="karte-vorschau">{stripHtml(n.text).slice(0, 120)}{stripHtml(n.text).length > 120 ? '…' : ''}</p>
{/if}
</li>
{/each}

View file

@ -137,7 +137,7 @@ async function main() {
console.log('→ Nachricht...');
await req('POST', '/nachrichten', {
betreff: 'Willkommen in vereins.haus!',
text: '<p>Hallo und herzlich willkommen! Dies ist eine Beispiel-Nachricht an alle Mitglieder.</p>',
text: 'Hallo und herzlich willkommen! Dies ist eine Beispiel-Nachricht an alle Mitglieder.',
gruppe_ids: [],
}, T);
console.log(` ✓ Nachricht erstellt`);