‪TYPO3CMS  11.5
SvgSanitizerTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Symfony\Component\Finder\Finder;
22 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
23 
24 class ‪SvgSanitizerTest extends FunctionalTestCase
25 {
29  protected ‪$initializeDatabase = false;
30 
34  public function svgContentIsSanitizedDataProvider(): array
35  {
36  $basePath = dirname(__FILE__, 2) . '/Fixtures/';
37  ‪$finder = new Finder();
39  ->files()
40  ->in($basePath . 'DirtySVG/')
41  ->name('*.svg');
42  ‪$data = [];
43  foreach (‪$finder as $file) {
44  $fileName = $file->getFilename();
45  ‪$data[$fileName] = [
46  $basePath . 'DirtySVG/' . $fileName,
47  $basePath . 'CleanSVG/' . $fileName,
48  ];
49  }
50  return ‪$data;
51  }
52 
57  public function ‪svgContentIsSanitized(string $filePath, string $sanitizedFilePath): void
58  {
59  $sanitizer = new SvgSanitizer();
60  self::assertStringEqualsFile(
61  $sanitizedFilePath,
62  $sanitizer->sanitizeContent(file_get_contents($filePath))
63  );
64  }
65 }
‪TYPO3\CMS\Core\Tests\Functional\Resource\Security\SvgSanitizerTest\$data
‪foreach($finder as $file) return $data
Definition: SvgSanitizerTest.php:42
‪TYPO3\CMS\Core\Tests\Functional\Resource\Security
Definition: SvgSanitizerTest.php:18
‪$finder
‪if(PHP_SAPI !=='cli') $finder
Definition: header-comment.php:22
‪TYPO3\CMS\Core\Tests\Functional\Resource\Security\SvgSanitizerTest\svgContentIsSanitized
‪svgContentIsSanitized(string $filePath, string $sanitizedFilePath)
Definition: SvgSanitizerTest.php:56
‪TYPO3\CMS\Core\Resource\Security\SvgSanitizer
Definition: SvgSanitizer.php:23
‪TYPO3\CMS\Core\Tests\Functional\Resource\Security\SvgSanitizerTest\$initializeDatabase
‪bool $initializeDatabase
Definition: SvgSanitizerTest.php:28
‪TYPO3\CMS\Core\Tests\Functional\Resource\Security\SvgSanitizerTest\$data
‪$data
Definition: SvgSanitizerTest.php:41
‪TYPO3\CMS\Core\Tests\Functional\Resource\Security\SvgSanitizerTest
Definition: SvgSanitizerTest.php:25