150d6f48cSGreg Roach<?php 23976b470SGreg Roach 350d6f48cSGreg Roach/** 450d6f48cSGreg Roach * webtrees: online genealogy 5*5e933c21SGreg Roach * Copyright (C) 2020 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 1550d6f48cSGreg Roach * along with this program. If not, see <http://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; 2350d6f48cSGreg Roach 2450d6f48cSGreg Roach/** 2550d6f48cSGreg Roach * Test harness for the class HtmlService 2650d6f48cSGreg Roach */ 2750d6f48cSGreg Roachclass HtmlServiceTest extends TestCase 2850d6f48cSGreg Roach{ 2950d6f48cSGreg Roach /** 3050d6f48cSGreg Roach * @covers \Fisharebest\Webtrees\Services\HtmlService::sanitize 3150d6f48cSGreg Roach * 3250d6f48cSGreg Roach * @return void 3350d6f48cSGreg Roach */ 3450d6f48cSGreg Roach public function testAllowedHtml(): void 3550d6f48cSGreg Roach { 3650d6f48cSGreg Roach $html_service = new HtmlService(); 3750d6f48cSGreg Roach 3850d6f48cSGreg Roach $dirty = '<div class="foo">bar</div>'; 3950d6f48cSGreg Roach $clean = $html_service->sanitize($dirty); 4050d6f48cSGreg Roach 41*5e933c21SGreg Roach self::assertSame($dirty, $clean); 4250d6f48cSGreg Roach } 4350d6f48cSGreg Roach 4450d6f48cSGreg Roach /** 4550d6f48cSGreg Roach * @covers \Fisharebest\Webtrees\Services\HtmlService::sanitize 4650d6f48cSGreg Roach * 4750d6f48cSGreg Roach * @return void 4850d6f48cSGreg Roach */ 4950d6f48cSGreg Roach public function testDisallowedHtml(): void 5050d6f48cSGreg Roach { 5150d6f48cSGreg Roach $html_service = new HtmlService(); 5250d6f48cSGreg Roach 5350d6f48cSGreg Roach $dirty = '<div class="foo" onclick="alert(123)">bar</div>'; 5450d6f48cSGreg Roach $clean = $html_service->sanitize($dirty); 5550d6f48cSGreg Roach 56*5e933c21SGreg Roach self::assertSame('<div class="foo">bar</div>', $clean); 5750d6f48cSGreg Roach } 5850d6f48cSGreg Roach} 59