Étendre le Markdown du site public

This commit is contained in:
Alexandre NOEL 2026-10-12 10:59:11 +02:00
commit 56a2fddc83
12 changed files with 179 additions and 52 deletions

View file

@ -296,6 +296,15 @@ try {
$assert(str_contains($image, '<img class="public-content-image"'));
$externalImage = PublicContentFormatter::render('![Piège](https://example.org/image.webp)');
$assert(!str_contains($externalImage, '<img'), 'Une image externe a été acceptée');
$markdown = PublicContentFormatter::render("| Nom | Prix |\n| :--- | ---: |\n| **Vaccin** | 27 € |\n\n1. Premier\n2. Second\n\n> Important\n\n`<script>`\n\n~~ancien~~");
$assert(str_contains($markdown, '<table>'), 'Les tableaux Markdown ne sont pas rendus');
$assert(str_contains($markdown, 'class="text-right"'), 'L’alignement des tableaux est perdu');
$assert(str_contains($markdown, '<ol>'), 'Les listes numérotées ne sont pas rendues');
$assert(str_contains($markdown, '<blockquote>'), 'Les citations ne sont pas rendues');
$assert(str_contains($markdown, '<code>&lt;script&gt;</code>'), 'Le code en ligne n’est pas protégé');
$assert(str_contains($markdown, '<del>ancien</del>'), 'Le texte barré n’est pas rendu');
$fenced = PublicContentFormatter::render("```html\n<script>alert(1)</script>\n```");
$assert(!str_contains($fenced, '<script>'), 'Le bloc de code permet une injection HTML');
});
$test('Le menu public affiche uniquement les réseaux sociaux configurés', function () use ($assert): void {
$layout = file_get_contents(__DIR__ . '/../app/Views/public_site_layout.php');