‪TYPO3CMS  9.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  public function svgContentIsSanitizedDataProvider(): array
30  {
31  $basePath = dirname(__FILE__, 2) . '/Fixtures/';
32  ‪$finder = new Finder();
34  ->files()
35  ->in($basePath . 'DirtySVG/')
36  ->name('*.svg');
37  ‪$data = [];
38  foreach (‪$finder as $file) {
39  $fileName = $file->getFilename();
40  ‪$data[$fileName] = ['DirtySVG/' . $fileName, 'CleanSVG/' . $fileName];
41  }
42  return ‪$data;
43  }
44 
51  public function ‪svgContentIsSanitized($filePath, $sanitizedFilePath)
52  {
53  $basePath = dirname(__FILE__, 2) . '/Fixtures/';
54  $sanitizer = new ‪SvgSanitizer();
55  self::assertStringEqualsFile(
56  $basePath . $sanitizedFilePath,
57  $sanitizer->sanitizeContent(file_get_contents($basePath . $filePath))
58  );
59  }
60 }
‪TYPO3\CMS\Core\Tests\Functional\Resource\Security\SvgSanitizerTest\$data
‪foreach($finder as $file) return $data
Definition: SvgSanitizerTest.php:38
‪TYPO3\CMS\Core\Tests\Functional\Resource\Security
Definition: SvgSanitizerTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\Resource\Security\SvgSanitizerTest\svgContentIsSanitized
‪svgContentIsSanitized($filePath, $sanitizedFilePath)
Definition: SvgSanitizerTest.php:51
‪$finder
‪$finder
Definition: annotationChecker.php:102
‪TYPO3\CMS\Core\Resource\Security\SvgSanitizer
Definition: SvgSanitizer.php:23
‪TYPO3\CMS\Core\Tests\Functional\Resource\Security\SvgSanitizerTest\$data
‪$data
Definition: SvgSanitizerTest.php:37
‪TYPO3\CMS\Core\Tests\Functional\Resource\Security\SvgSanitizerTest
Definition: SvgSanitizerTest.php:25