* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * License as published by the Free Software Foundation; either * version 3 of the License, or any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this library. If not, see . * */ namespace Test; class TemplateFunctionsTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); require_once \OC::$SERVERROOT . '/lib/private/legacy/OC_Template.php'; } public function testPJavaScript() { $this->expectOutputString('<img onload="alert(1)" />'); p(''); } public function testPJavaScriptWithScriptTags() { $this->expectOutputString('<script>alert('Hacked!');</script>'); p(""); } public function testPNormalString() { $string = 'This is a good string without HTML.'; $this->expectOutputString($string); p($string); } public function testPrintUnescaped() { $htmlString = ""; $this->expectOutputString($htmlString); print_unescaped($htmlString); } public function testPrintUnescapedNormalString() { $string = 'This is a good string!'; $this->expectOutputString($string); print_unescaped($string); } public function testEmitScriptTagWithContent() { $this->expectOutputRegex('/