150d6f48cSGreg Roach<?php 23976b470SGreg Roach 350d6f48cSGreg Roach/** 450d6f48cSGreg Roach * webtrees: online genealogy 5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 650d6f48cSGreg Roach * This program is free software: you can redistribute it and/or modify 750d6f48cSGreg Roach * it under the terms of the GNU General Public License as published by 850d6f48cSGreg Roach * the Free Software Foundation, either version 3 of the License, or 950d6f48cSGreg Roach * (at your option) any later version. 1050d6f48cSGreg Roach * This program is distributed in the hope that it will be useful, 1150d6f48cSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 1250d6f48cSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1350d6f48cSGreg Roach * GNU General Public License for more details. 1450d6f48cSGreg Roach * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 1650d6f48cSGreg Roach */ 17fcfa147eSGreg Roach 1850d6f48cSGreg Roachdeclare(strict_types=1); 1950d6f48cSGreg Roach 2050d6f48cSGreg Roachnamespace Fisharebest\Webtrees\Services; 2150d6f48cSGreg Roach 2250d6f48cSGreg Roachuse Fisharebest\Webtrees\TestCase; 23*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass; 2450d6f48cSGreg Roach 25*202c018bSGreg Roach#[CoversClass(HtmlService::class)] 2650d6f48cSGreg Roachclass HtmlServiceTest extends TestCase 2750d6f48cSGreg Roach{ 2850d6f48cSGreg Roach public function testAllowedHtml(): void 2950d6f48cSGreg Roach { 3050d6f48cSGreg Roach $html_service = new HtmlService(); 3150d6f48cSGreg Roach 3250d6f48cSGreg Roach $dirty = '<div class="foo">bar</div>'; 3350d6f48cSGreg Roach $clean = $html_service->sanitize($dirty); 3450d6f48cSGreg Roach 355e933c21SGreg Roach self::assertSame($dirty, $clean); 3650d6f48cSGreg Roach } 3750d6f48cSGreg Roach 3850d6f48cSGreg Roach public function testDisallowedHtml(): void 3950d6f48cSGreg Roach { 4050d6f48cSGreg Roach $html_service = new HtmlService(); 4150d6f48cSGreg Roach 4250d6f48cSGreg Roach $dirty = '<div class="foo" onclick="alert(123)">bar</div>'; 4350d6f48cSGreg Roach $clean = $html_service->sanitize($dirty); 4450d6f48cSGreg Roach 455e933c21SGreg Roach self::assertSame('<div class="foo">bar</div>', $clean); 4650d6f48cSGreg Roach } 4750d6f48cSGreg Roach} 48