21 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerFactory;
22 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerWriter;
23 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\Internal\AbstractInstruction;
24 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\Internal\TypoScriptInstruction;
25 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
26 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequestContext;
27 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalResponse;
28 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
37 private const ENCRYPTION_KEY =
'4408d27a916d51e624b69af3554f516dbab61037a9f7b9fd6f81b4d3bedeccb6';
46 'EN' => [
'id' => 0,
'title' =>
'English',
'locale' =>
'en_US.UTF8',
'iso' =>
'en',
'hrefLang' =>
'en-US',
'direction' =>
''],
63 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/AdditionalConfiguration.php' =>
'typo3conf/AdditionalConfiguration.php',
68 parent::setUpBeforeClass();
69 static::initializeDatabaseSnapshot();
74 static::destroyDatabaseSnapshot();
75 parent::tearDownAfterClass();
78 protected function setUp(): void
83 $this->internalRequestContext = (
new InternalRequestContext())
84 ->withGlobalSettings([
'TYPO3_CONF_VARS' => static::TYPO3_CONF_VARS]);
92 $this->withDatabaseSnapshot(
function () {
99 $backendUser = $this->setUpBackendUserFromFixture(1);
102 $scenarioFile = __DIR__ .
'/Fixtures/SecureHtmlScenario.yaml';
103 $factory = DataHandlerFactory::fromYamlFile($scenarioFile);
104 $writer = DataHandlerWriter::withBackendUser($backendUser);
105 $writer->invokeFactory($factory);
106 static::failIfArrayIsNotEmpty(
110 $this->setUpFrontendRootPage(
113 'constants' => [
'EXT:fluid_styled_content/Configuration/TypoScript/constants.typoscript'],
114 'setup' => [
'EXT:fluid_styled_content/Configuration/TypoScript/setup.typoscript'],
117 'title' =>
'ACME Root',
124 unset($this->internalRequestContext);
132 '01: <script>alert(1)</script>',
133 '<p>01: <script>alert(1)</script></p>',
136 '02: <unknown a="a" b="b">value</unknown>',
137 '<p>02: <unknown a="a" b="b">value</unknown></p>',
140 '03: <img img="img" alt="alt" onerror="alert(1)">',
141 '<p>03: <img alt="alt"></p>',
144 '04: <img src="img" alt="alt" onerror="alert(1)">',
145 '<p>04: <img src="img" alt="alt"></p>',
148 '05: <img/src="img"/onerror="alert(1)">',
149 '<p>05: <img/src="img"/onerror="alert(1)"></p>',
152 '06: <strong>Given that x < y and y > z...</strong>',
153 '<p>06: <strong>Given that x < y and y > z...</strong></p>',
156 '07: <a href="t3://page?uid=1000" target="_blank" rel="noreferrer" class="button" role="button" onmouseover="alert(1)">TYPO3</a>',
157 '<p>07: <a href="/" target="_blank" rel="noreferrer" class="button" role="button">TYPO3</a></p>',
174 self::assertSame($expectation, (
string)$response->getBody());
181 '01: <script>alert(1)</script>',
182 '<p>01: <script>alert(1)</script></p>',
185 '02: <unknown a="a" b="b">value</unknown>',
186 '<p>02: <unknown a="a" b="b">value</unknown></p>',
189 '03: <img img="img" alt="alt" onerror="alert(1)">',
190 '<p>03: <img alt="alt"></p>',
193 '04: <img src="img" alt="alt" onerror="alert(1)">',
194 '<p>04: <img src="img" alt="alt"></p>',
197 '05: <img/src="img"/onerror="alert(1)">',
198 '<p>05: <img src="img"></p>',
201 '06: <strong>Given that x < y and y > z...</strong>',
202 '<p>06: <strong>Given that x y and y > z...</strong></p>',
205 '07: <a href="t3://page?uid=1000" target="_blank" rel="noreferrer" class="button" role="button" onmouseover="alert(1)">TYPO3</a>',
206 '<p>07: <a href="/" target="_blank" rel="noreferrer" class="button" role="button">TYPO3</a></p>',
223 self::assertSame($expectation, (
string)$response->getBody());
229 '#01 ' . self::TYPE_PLAIN => [
231 '01: <script>alert(1)</script>',
232 '<p>01: <script>alert(1)</script></p>',
234 '#01 ' . self::TYPE_EMPTY_PARSEFUNCTSPATH => [
236 '01: <script>alert(1)</script>',
237 '01: <script>alert(1)</script>',
239 '#01 ' . self::TYPE_DISABLE_HTML_SANITIZE => [
241 '01: <script>alert(1)</script>',
242 '<p>01: <script>alert(1)</script></p>',
244 '#03 ' . self::TYPE_PLAIN => [
246 '03: <img img="img" alt="alt" onerror="alert(1)">',
247 '<p>03: <img alt="alt"></p>',
249 '#03 ' . self::TYPE_EMPTY_PARSEFUNCTSPATH => [
251 '03: <img img="img" alt="alt" onerror="alert(1)">',
252 '03: <img img="img" alt="alt" onerror="alert(1)">',
254 '#03 ' . self::TYPE_DISABLE_HTML_SANITIZE => [
256 '03: <img img="img" alt="alt" onerror="alert(1)">',
257 '<p>03: <img img="img" alt="alt" onerror="alert(1)"></p>',
259 '#07 ' . self::TYPE_PLAIN => [
261 '07: <a href="t3://page?uid=1000" target="_blank" rel="noreferrer" class="button" role="button" onmouseover="alert(1)">TYPO3</a>',
262 '<p>07: <a href="/" target="_blank" rel="noreferrer" class="button" role="button">TYPO3</a></p>',
264 '#07 ' . self::TYPE_EMPTY_PARSEFUNCTSPATH => [
266 '07: <a href="t3://page?uid=1000" target="_blank" rel="noreferrer" class="button" role="button" onmouseover="alert(1)">TYPO3</a>',
268 '07: <a href="t3://page?uid=1000" target="_blank" rel="noreferrer" class="button" role="button" onmouseover="alert(1)">TYPO3</a>',
270 '#07 ' . self::TYPE_DISABLE_HTML_SANITIZE => [
272 '07: <a href="t3://page?uid=1000" target="_blank" rel="noreferrer" class="button" role="button" onmouseover="alert(1)">TYPO3</a>',
273 '<p>07: <a href="/" target="_blank" rel="noreferrer" class="button" role="button" onmouseover="alert(1)">TYPO3</a></p>',
275 '#08 ' . self::TYPE_PLAIN => [
277 '08: <meta whatever="whatever">',
280 '#08 ' . self::TYPE_EMPTY_PARSEFUNCTSPATH => [
282 '08: <meta whatever="whatever">',
283 '08: <meta whatever="whatever">',
285 '#08 ' . self::TYPE_DISABLE_HTML_SANITIZE => [
287 '08: <meta whatever="whatever">',
288 '<p>08: <meta whatever="whatever"></p>',
291 '#09 ' . self::TYPE_PLAIN => [
293 '09: <sdfield onmouseover="alert(1)">',
294 '<p>09: <sdfield onmouseover="alert(1)"></sdfield></p>',
296 '#09 ' . self::TYPE_EMPTY_PARSEFUNCTSPATH => [
298 '09: <sdfield onmouseover="alert(1)">',
299 '09: <sdfield onmouseover="alert(1)">',
301 '#09 ' . self::TYPE_DISABLE_HTML_SANITIZE => [
303 '09: <sdfield onmouseover="alert(1)">',
304 '<p>09: <sdfield onmouseover="alert(1)"></p>',
306 '#10 ' . self::TYPE_PLAIN => [
308 '10: <meta itemprop="type" content="voice">',
309 '<p>10: <meta itemprop="type" content="voice"></p>',
311 '#10 ' . self::TYPE_EMPTY_PARSEFUNCTSPATH => [
313 '10: <meta itemprop="type" content="voice">',
314 '10: <meta itemprop="type" content="voice">',
316 '#10 ' . self::TYPE_DISABLE_HTML_SANITIZE => [
318 '10: <meta itemprop="type" content="voice">',
319 '<p>10: <meta itemprop="type" content="voice"></p>',
336 if ($type === self::TYPE_DISABLE_HTML_SANITIZE) {
340 self::assertSame($expectation, trim((
string)$response->getBody(),
"\n"));
349 $sourcePageId = 1100;
351 $request = (
new InternalRequest(
'https://acme.us/'))
352 ->withPageId($sourcePageId)
359 if (count($instructions) > 0) {
363 return $this->executeFrontendRequest($request, $this->internalRequestContext);
368 return (
new TypoScriptInstruction(TemplateService::class))
374 'disableAllHeaderCode' => 1,
375 'sendCacheHeaders' => 0,
387 return (
new TypoScriptInstruction(TemplateService::class))
393 'parseFunc' =>
'< lib.parseFunc_RTE',
404 return (
new TypoScriptInstruction(TemplateService::class))
411 'allowTags' =>
'a,img,sdfield',
418 'data' =>
'parameters:href'
421 'data' =>
'parameters:title'
424 'data' =>
'parameters:allParams'
429 'nonTypoTagStdWrap.' => [
431 'nonWrappedTag' =>
'p',
442 return (
new TypoScriptInstruction(TemplateService::class))
445 'parseFunc_RTE.' => [
446 'htmlSanitize' =>
'0',
454 return (
new TypoScriptInstruction(TemplateService::class))
457 '10' =>
'FLUIDTEMPLATE',
459 'file' =>
'EXT:fluid_styled_content/Tests/Functional/Rendering/Fixtures/FluidTemplate.html',