‪TYPO3CMS  11.5
HtmlParserTest.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 
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
26 class ‪HtmlParserTest extends UnitTestCase
27 {
29 
30  protected function ‪setUp(): void
31  {
32  parent::setUp();
33  $this->subject = new ‪HtmlParser();
34  }
35 
40  {
41  return [
42  'single-line CDATA' => [
43  '/*<![CDATA[*/ <hello world> /*]]>*/',
44  '/*<![CDATA[*/ <hello world> /*]]>*/',
45  ],
46  'multi-line CDATA #1' => [
47  '/*<![CDATA[*/' . LF . '<hello world> /*]]>*/',
48  '/*<![CDATA[*/' . LF . '<hello world> /*]]>*/',
49  ],
50  'multi-line CDATA #2' => [
51  '/*<![CDATA[*/ <hello world>' . LF . '/*]]>*/',
52  '/*<![CDATA[*/ <hello world>' . LF . '/*]]>*/',
53  ],
54  'multi-line CDATA #3' => [
55  '/*<![CDATA[*/' . LF . '<hello world>' . LF . '/*]]>*/',
56  '/*<![CDATA[*/' . LF . '<hello world>' . LF . '/*]]>*/',
57  ],
58  ];
59  }
60 
66  public function ‪splitIntoBlockDataProvider(): array
67  {
68  return [
69  'splitBlock' => [
70  'h1,span',
71  '<body><h1>Title</h1><span>Note</span></body>',
72  false,
73  [
74  '<body>',
75  '<h1>Title</h1>',
76  '',
77  '<span>Note</span>',
78  '</body>',
79  ],
80  ],
81  'splitBlock br' => [
82  'h1,span',
83  '<body><h1>Title</h1><br /><span>Note</span><br /></body>',
84  false,
85  [
86  '<body>',
87  '<h1>Title</h1>',
88  '<br />',
89  '<span>Note</span>',
90  '<br /></body>',
91  ],
92  ],
93  'splitBlock with attribute' => [
94  'h1,span',
95  '<body><h1 class="title">Title</h1><span>Note</span></body>',
96  false,
97  [
98  '<body>',
99  '<h1 class="title">Title</h1>',
100  '',
101  '<span>Note</span>',
102  '</body>',
103  ],
104  ],
105  'splitBlock span with attribute' => [
106  'span',
107  '<body><h1>Title</h1><span class="title">Note</span></body>',
108  false,
109  [
110  '<body><h1>Title</h1>',
111  '<span class="title">Note</span>',
112  '</body>',
113  ],
114  ],
115  'splitBlock without extra end tags' => [
116  'h1,span,div',
117  '<body><h1>Title</h1><span>Note</span></body></div>',
118  true,
119  [
120  '<body>',
121  '<h1>Title</h1>',
122  '',
123  '<span>Note</span>',
124  '</body>',
125  ],
126  ],
127  ];
128  }
129 
138  public function ‪splitIntoBlock(string $tag, string $content, bool $eliminateExtraEndTags, array $expected): void
139  {
140  self::assertSame($expected, $this->subject->splitIntoBlock($tag, $content, $eliminateExtraEndTags));
141  }
142 
149  public function ‪xHtmlCleaningDoesNotModifyCDATA(string $source, string $expected): void
150  {
151  $result = $this->subject->HTMLcleaner($source, [], 1);
152  self::assertSame($expected, $result);
153  }
154 
159  public function ‪htmlCleanerKeepsSingleTagsWithAndWithoutEndingSlashUnchanged(string $exampleString): void
160  {
161  $result = $this->subject->HTMLcleaner($exampleString, ['br' => true], 0);
162  self::assertSame($exampleString, $result);
163  }
164 
168  public static function ‪htmlWithDifferentSingleTagsDataProvider(): array
169  {
170  return [
171  'no slash' => ['one<br>two'],
172  'slash without space' => ['one<br/>two'],
173  'space and slash' => ['one<br />two'],
174  ];
175  }
176 
181  {
182  return [
183  'Span tag with no attrib' => [
184  '<span>text</span>',
185  'text',
186  ],
187  'Span tag with allowed id attrib' => [
188  '<span id="id">text</span>',
189  '<span id="id">text</span>',
190  ],
191  'Span tag with disallowed style attrib' => [
192  '<span style="line-height: 12px;">text</span>',
193  'text',
194  ],
195  ];
196  }
197 
204  public function ‪tagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured(string $content, string $expectedResult): void
205  {
206  $tsConfig = [
207  'allowTags' => 'span',
208  'tags.' => [
209  'span.' => [
210  'allowedAttribs' => 'id',
211  'rmTagIfNoAttrib' => 1,
212  ],
213  ],
214  ];
215  self::assertEquals($expectedResult, $this->‪parseConfigAndCleanHtml($tsConfig, $content));
216  }
217 
222  {
223  $tsConfig = [
224  'allowTags' => 'div,span',
225  'rmTagIfNoAttrib' => 'span',
226  'globalNesting' => 'div,span',
227  ];
228  $content = '<span></span><span id="test"><div></span></div>';
229  $expectedResult = '<span id="test"></span>';
230  self::assertEquals($expectedResult, $this->‪parseConfigAndCleanHtml($tsConfig, $content));
231  }
232 
239  {
240  return [
241  'Valid nesting is untouched' => [
242  '<B><I></B></I>',
243  '<B><I></B></I>',
244  ],
245  'Valid nesting with content is untouched' => [
246  'testa<B>test1<I>test2</B>test3</I>testb',
247  'testa<B>test1<I>test2</B>test3</I>testb',
248  ],
249  'Superfluous tags are removed' => [
250  '</B><B><I></B></I></B>',
251  '<B><I></B></I>',
252  ],
253  'Superfluous tags with content are removed' => [
254  'test1</B>test2<B>test3<I>test4</B>test5</I>test6</B>test7',
255  'test1test2<B>test3<I>test4</B>test5</I>test6test7',
256  ],
257  'Another valid nesting test' => [
258  '<span><div></span></div>',
259  '<span><div></span></div>',
260  ],
261  ];
262  }
263 
270  public function ‪localNestingCorrectlyRemovesInvalidTags(string $content, string $expectedResult): void
271  {
272  $tsConfig = [
273  'allowTags' => 'div,span,b,i',
274  'localNesting' => 'div,span,b,i',
275  ];
276  self::assertEquals($expectedResult, $this->‪parseConfigAndCleanHtml($tsConfig, $content));
277  }
278 
285  {
286  return [
287  'Valid nesting is untouched' => [
288  '<B><I></I></B>',
289  '<B><I></I></B>',
290  ],
291  'Valid nesting with content is untouched' => [
292  'testa<B>test1<I>test2</I>test3</B>testb',
293  'testa<B>test1<I>test2</I>test3</B>testb',
294  ],
295  'Invalid nesting is cleaned' => [
296  '</B><B><I></B></I></B>',
297  '<B></B>',
298  ],
299  'Invalid nesting with content is cleaned' => [
300  'test1</B>test2<B>test3<I>test4</B>test5</I>test6</B>test7',
301  'test1test2<B>test3test4</B>test5test6test7',
302  ],
303  'Another invalid nesting test' => [
304  '<span><div></span></div>',
305  '<span></span>',
306  ],
307  ];
308  }
309 
316  public function ‪globalNestingCorrectlyRemovesInvalidTags(string $content, string $expectedResult): void
317  {
318  $tsConfig = [
319  'allowTags' => 'span,div,b,i',
320  'globalNesting' => 'span,div,b,i',
321  ];
322  self::assertEquals($expectedResult, $this->‪parseConfigAndCleanHtml($tsConfig, $content));
323  }
324 
328  public function ‪emptyTagsDataProvider(): array
329  {
330  return [
331  [false, null, false, '<h1></h1>', '<h1></h1>'],
332  [true, null, false, '<h1></h1>', ''],
333  [true, null, false, '<h1>hallo</h1>', '<h1>hallo</h1>'],
334  [true, null, false, '<h1 class="something"></h1>', ''],
335  [true, null, false, '<h1 class="something"></h1><h2></h2>', ''],
336  [true, 'h2', false, '<h1 class="something"></h1><h2></h2>', '<h1 class="something"></h1>'],
337  [true, 'h2, h1', false, '<h1 class="something"></h1><h2></h2>', ''],
338  [true, null, false, '<div><p></p></div>', ''],
339  [true, null, false, '<div><p>&nbsp;</p></div>', '<div><p>&nbsp;</p></div>'],
340  [true, null, true, '<div><p>&nbsp;&nbsp;</p></div>', ''],
341  [true, null, true, '<div>&nbsp;&nbsp;<p></p></div>', ''],
342  [true, null, false, '<div>Some content<p></p></div>', '<div>Some content</div>'],
343  [true, null, true, '<div>Some content<p></p></div>', '<div>Some content</div>'],
344  [true, null, false, '<div>Some content</div>', '<div>Some content</div>'],
345  [true, null, true, '<div>Some content</div>', '<div>Some content</div>'],
346  [true, null, false, '<a href="#skiplinks">Skiplinks </a><b></b>', '<a href="#skiplinks">Skiplinks </a>'],
347  [true, null, true, '<a href="#skiplinks">Skiplinks </a><b></b>', '<a href="#skiplinks">Skiplinks </a>'],
348  [false, '', false, '<h1></h1>', '<h1></h1>'],
349  [true, '', false, '<h1></h1>', ''],
350  [true, '', false, '<h1>hallo</h1>', '<h1>hallo</h1>'],
351  [true, '', false, '<h1 class="something"></h1>', ''],
352  [true, '', false, '<h1 class="something"></h1><h2></h2>', ''],
353  [true, '', false, '<div><p></p></div>', ''],
354  [true, '', false, '<div><p>&nbsp;</p></div>', '<div><p>&nbsp;</p></div>'],
355  [true, '', true, '<div><p>&nbsp;&nbsp;</p></div>', ''],
356  [true, '', true, '<div>&nbsp;&nbsp;<p></p></div>', ''],
357  [true, '', false, '<div>Some content<p></p></div>', '<div>Some content</div>'],
358  [true, '', true, '<div>Some content<p></p></div>', '<div>Some content</div>'],
359  [true, '', false, '<div>Some content</div>', '<div>Some content</div>'],
360  [true, '', true, '<div>Some content</div>', '<div>Some content</div>'],
361  [true, '', false, '<a href="#skiplinks">Skiplinks </a><b></b>', '<a href="#skiplinks">Skiplinks </a>'],
362  [true, '', true, '<a href="#skiplinks">Skiplinks </a><b></b>', '<a href="#skiplinks">Skiplinks </a>'],
363  ];
364  }
365 
375  public function ‪stripEmptyTags(
376  bool $stripOn,
377  $tagList,
378  bool $treatNonBreakingSpaceAsEmpty,
379  string $content,
380  string $expectedResult
381  ): void {
382  $tsConfig = [
383  'keepNonMatchedTags' => 1,
384  'stripEmptyTags' => $stripOn,
385  'stripEmptyTags.' => [
386  'tags' => $tagList,
387  'treatNonBreakingSpaceAsEmpty' => $treatNonBreakingSpaceAsEmpty,
388  ],
389  ];
390 
391  $result = $this->‪parseConfigAndCleanHtml($tsConfig, $content);
392  self::assertEquals($expectedResult, $result);
393  }
394 
399  {
400  return [
401  [
402  'tr,td',
403  false,
404  '<div><p><tr><td></td></tr></p></div><div class="test"></div><tr></tr><p></p><td></td><i></i>',
405  '<div><p><tr><td></td></tr></p></div><tr></tr><td></td>',
406  ],
407  [
408  'tr,td',
409  true,
410  '<div><p><tr><td></td></tr></p></div><p class="test"> &nbsp; </p><tr></tr><p></p><td></td><i></i>',
411  '<div><p><tr><td></td></tr></p></div><tr></tr><td></td>',
412  ],
413  ];
414  }
415 
425  string $tagList,
426  bool $treatNonBreakingSpaceAsEmpty,
427  string $content,
428  string $expectedResult
429  ): void {
430  $tsConfig = [
431  'keepNonMatchedTags' => 1,
432  'stripEmptyTags' => 1,
433  'stripEmptyTags.' => [
434  'keepTags' => $tagList,
435  'treatNonBreakingSpaceAsEmpty' => $treatNonBreakingSpaceAsEmpty,
436  ],
437  ];
438 
439  $result = $this->‪parseConfigAndCleanHtml($tsConfig, $content);
440  self::assertEquals($expectedResult, $result);
441  }
442 
450  protected function ‪parseConfigAndCleanHtml(array $tsConfig, string $content): string
451  {
452  $config = $this->subject->HTMLparserConfig($tsConfig);
453  return $this->subject->HTMLcleaner($content, $config[0], $config[1], $config[2], $config[3]);
454  }
455 
461  public function ‪getFirstTagDataProvider(): array
462  {
463  return [
464  ['<body><span></span></body>', '<body>'],
465  ['<span>Wrapper<div>Some content</div></span>', '<span>'],
466  ['Something before<span>Wrapper<div>Some content</div></span>Something after', 'Something before<span>'],
467  ['Something without tag', ''],
468  ['text</span>', 'text</span>'],
469  ['<span class=<other><inner></span>', '<span class=<other>'],
470  ['<sp-an class=<other><inner></sp-an>', '<sp-an class=<other>'],
471  ['<span/class=<other><inner></span>', '<span/class=<other>'],
472  ['<span class="<other>"><inner></span>', '<span class="<other>">'],
473  ['<span class=""<other>""><inner></span>', '<span class=""<other>'],
474  ['<span class=<other>>><inner></span>', '<span class=<other>'],
475  ['<span class="', ''],
476  ['<span class=""', ''],
477  ['<span class="<"', ''],
478  ['<span class=">"', ''],
479  ['<span class="<other><inner></span>', ''],
480  ["<span class='<other><inner></span>", ''],
481  ['<span class="<other>\'<inner></span>', ''],
482  ["<span class='<other>\"<inner></span>", ''],
483  ];
484  }
485 
496  public function ‪getFirstTag(string $str, string $expected): void
497  {
498  self::assertEquals($expected, $this->subject->getFirstTag($str));
499  }
500 
506  public function ‪getFirstTagNameDataProvider(): array
507  {
508  return [
509  [
510  '<body><span></span></body>',
511  false,
512  'BODY',
513  ],
514  [
515  '<body><span></span></body>',
516  true,
517  'body',
518  ],
519  [
520  '<div class="test"><span></span></div>',
521  false,
522  'DIV',
523  ],
524  [
525  '<div><span class="test"></span></div>',
526  false,
527  'DIV',
528  ],
529  [
530  '<br /><span class="test"></span>',
531  false,
532  'BR',
533  ],
534  [
535  '<img src="test.jpg" />',
536  false,
537  'IMG',
538  ],
539  ['text</span>', false, ''],
540  ['<span class=<other><inner></span>', false, 'SPAN'],
541  ['<sp-an class=<other><inner></sp-an>', false, 'SP-AN'],
542  ['<span/class=<other><inner></span>', false, 'SPAN'],
543  ['<span class="<other>"><inner></span>', false, 'SPAN'],
544  ['<span class=""<other>""><inner></span>', false, 'SPAN'],
545  ['<span class=<other>>><inner></span>', false, 'SPAN'],
546  ['<span class="', false, ''],
547  ['<span class=""', false, ''],
548  ['<span class="<"', false, ''],
549  ['<span class=">"', false, ''],
550  ['<span class="<other><inner></span>', false, ''],
551  ["<span class='<other><inner></span>", false, ''],
552  ['<span class="<other>\'<inner></span>', false, ''],
553  ["<span class='<other>\"<inner></span>", false, ''],
554 
555  ];
556  }
557 
568  public function ‪getFirstTagName(string $str, bool $preserveCase, string $expected): void
569  {
570  self::assertEquals($expected, $this->subject->getFirstTagName($str, $preserveCase));
571  }
572 
576  public function ‪removeFirstAndLastTagDataProvider(): array
577  {
578  return [
579  ['<span>Wrapper<div>Some content</div></span>', 'Wrapper<div>Some content</div>'],
580  ['<td><tr>Some content</tr></td>', '<tr>Some content</tr>'],
581  [
582  'Something before<span>Wrapper<div>Some content</div></span>Something after',
583  'Wrapper<div>Some content</div>',
584  ],
585  ['<span class="hidden">Wrapper<div>Some content</div></span>', 'Wrapper<div>Some content</div>'],
586  [
587  '<span>Wrapper<div class="hidden">Some content</div></span>',
588  'Wrapper<div class="hidden">Some content</div>',
589  ],
590  [
591  'Some stuff before <span>Wrapper<div class="hidden">Some content</div></span> and after',
592  'Wrapper<div class="hidden">Some content</div>',
593  ],
594  ['text', ''],
595  ['<span>text', ''],
596  ['text</span>', ''],
597  ['<span class=<other><inner></span>', '<inner>'],
598  ['<sp-an class=<other><inner></sp-an>', '<inner>'],
599  ['<span/class=<other><inner></span>', '<inner>'],
600  ['<span class="<other>"><inner></span>', '<inner>'],
601  ['<span class=""<other>""><inner></span>', '""><inner>'],
602  ['<span class=<other>>><inner></span>', '>><inner>'],
603  ['<span class="', ''],
604  ['<span class=""', ''],
605  ['<span class="<"', ''],
606  ['<span class=">"', ''],
607  ['<span class="<other><inner></span>', ''],
608  ["<span class='<other><inner></span>", ''],
609  ['<span class="<other>\'<inner></span>', ''],
610  ["<span class='<other>\"<inner></span>", ''],
611  ];
612  }
613 
623  public function ‪removeFirstAndLastTag(string $str, string $expectedResult): void
624  {
625  self::assertEquals($expectedResult, $this->subject->removeFirstAndLastTag($str));
626  }
627 
631  public function ‪getTagAttributesDataProvider(): array
632  {
633  return [
634  [
635  '<a href="" data-shortCut="DXB" required>',
636  [
637  ['href' => '', 'data-shortcut' => 'DXB', 'required' => ''],
638  [
639  'href' => ['origTag' => 'href', 'dashType' => '"'],
640  'data-shortcut' => ['origTag' => 'data-shortCut', 'dashType' => '"'],
641  'required' => ['origTag' => 'required'],
642  ],
643  ],
644  ],
645  [
646  '<ul STYLE=\'background-image: (url: "fra.png")\' data-shortcut=FRA>',
647  [
648  ['style' => 'background-image: (url: "fra.png")', 'data-shortcut' => 'FRA'],
649  [
650  'style' => ['origTag' => 'STYLE', 'dashType' => '\''],
651  'data-shortcut' => ['origTag' => 'data-shortcut', 'dashType' => ''],
652  ],
653  ],
654  ],
655 
656  ];
657  }
658 
668  public function ‪getTagAttributes(string $tag, array $expectedResult): void
669  {
670  self::assertEquals($expectedResult, $this->subject->get_tag_attributes($tag));
671  }
672 
676  public function ‪stripEmptyTagsDataProvider(): array
677  {
678  return [
679  // Testing wrongly encapsulated and upper/lowercase tags
680  [
681  '<div>Denpassar</div><p> Bali</P><p></p><P></p><ul><li></li></ul>',
682  '',
683  false,
684  '<div>Denpassar</div><p> Bali</P>',
685  ],
686  // Testing incomplete tags
687  [
688  '<p><div>Klungklung</div></p><p> Semarapura<p></p><p></p><ul><li></li></ul>',
689  '',
690  false,
691  '<p><div>Klungklung</div></p><p> Semarapura',
692  ],
693  // Testing third parameter (break spaces
694  [
695  '<p><div>Badung</div></p><ul> Mangupura<p></p><p></p><ul><li>&nbsp;</li><li>Uluwatu</li></ul>',
696  '',
697  true,
698  '<p><div>Badung</div></p><ul> Mangupura<ul><li>Uluwatu</li></ul>',
699  ],
700  // Testing fourth parameter (keeping empty other tags, keeping defined used tags)
701  [
702  '<p><div>Badung</div></p><ul> Mangupura<p></p><p></p><ul><li></li></ul>',
703  'p,div',
704  true,
705  '<p><div>Badung</div></p><ul> Mangupura<ul><li></li></ul>',
706  ],
707 
708  ];
709  }
710 
722  public function ‪rawStripEmptyTagsTest(
723  string $content,
724  string $tagList,
725  bool $treatNonBreakingSpaceAsEmpty,
726  string $expectedResult
727  ): void {
728  self::assertEquals(
729  $expectedResult,
730  $this->subject->stripEmptyTags($content, $tagList, $treatNonBreakingSpaceAsEmpty)
731  );
732  }
733 
734  public function ‪prefixResourcePathDataProvider(): array
735  {
736  return [
737  '<td background="test.png">' => [
738  '<table><tr><td background="test.png">Test</td></tr></table>',
739  '/prefix/',
740  '<table><tr><td background="/prefix/test.png">Test</td></tr></table>',
741 
742  ],
743  '<table background="test.png">' => [
744  '<table background="test.png"><tr><td>Test</td></tr></table>',
745  '/prefix/',
746  '<table background="/prefix/test.png"><tr><td>Test</td></tr></table>',
747  ],
748  '<body background="test.png">' => [
749  '<body background="test.png">',
750  '/prefix/',
751  '<body background="/prefix/test.png">',
752  ],
753  '<img src="test.png">' => [
754  '<img src="test.png">',
755  '/prefix/',
756  '<img src="/prefix/test.png">',
757  ],
758  '<input src="test.png">' => [
759  '<input type="image" src="test.png"/>',
760  '/prefix/',
761  '<input type="image" src="/prefix/test.png" />',
762  ],
763  '<script src="test.js">' => [
764  '<script src="test.js"/>',
765  '/assets/',
766  '<script src="/assets/test.js" />',
767  ],
768  '<embed src="test.swf">' => [
769  '<embed src="test.swf"></embed>',
770  '/media/',
771  '<embed src="/media/test.swf"></embed>',
772  ],
773  '<a href="test.pdf">' => [
774  '<a href="something/test.pdf">Test PDF</a>',
775  '/',
776  '<a href="/something/test.pdf">Test PDF</a>',
777  ],
778  '<link href="test.css">' => [
779  '<link rel="stylesheet" type="text/css" href="theme.css">',
780  '/css/',
781  '<link rel="stylesheet" type="text/css" href="/css/theme.css">',
782  ],
783  '<form action="test/">' => [
784  '<form action="test/"></form>',
785  '/',
786  '<form action="/test/"></form>',
787  ],
788  '<param name="movie" value="test.mp4">' => [
789  '<param name="movie" value="test.mp4" />',
790  '/test/',
791  '<param name="movie" value="/test/test.mp4" />',
792  ],
793  '<source srcset="large.jpg">' => [
794  '<source srcset="large.jpg">',
795  '/assets/',
796  '<source srcset="/assets/large.jpg">',
797  ],
798  '<source media="(min-width: 56.25em)" srcset="large.jpg 1x, large@2x.jpg 2x">' => [
799  '<source media="(min-width: 56.25em)" srcset="large.jpg 1x, large@2x.jpg 2x">',
800  '/assets/',
801  '<source media="(min-width: 56.25em)" srcset="/assets/large.jpg 1x, /assets/large@2x.jpg 2x">',
802  ],
803  ];
804  }
805 
810  public function ‪prefixResourcePathTest(string $content, string $prefix, string $expectedResult): void
811  {
812  self::assertSame(
813  $expectedResult,
814  $this->subject->prefixResourcePath($prefix, $content)
815  );
816  }
817 }
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\localNestingCorrectlyRemovesInvalidTags
‪localNestingCorrectlyRemovesInvalidTags(string $content, string $expectedResult)
Definition: HtmlParserTest.php:270
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\stripEmptyTagsKeepsConfiguredTags
‪stripEmptyTagsKeepsConfiguredTags(string $tagList, bool $treatNonBreakingSpaceAsEmpty, string $content, string $expectedResult)
Definition: HtmlParserTest.php:424
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\splitIntoBlock
‪splitIntoBlock(string $tag, string $content, bool $eliminateExtraEndTags, array $expected)
Definition: HtmlParserTest.php:138
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\xHtmlCleaningDoesNotModifyCDATA
‪xHtmlCleaningDoesNotModifyCDATA(string $source, string $expected)
Definition: HtmlParserTest.php:149
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfiguredDataProvider
‪static spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfiguredDataProvider()
Definition: HtmlParserTest.php:180
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\htmlCleanerKeepsSingleTagsWithAndWithoutEndingSlashUnchanged
‪htmlCleanerKeepsSingleTagsWithAndWithoutEndingSlashUnchanged(string $exampleString)
Definition: HtmlParserTest.php:159
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\setUp
‪setUp()
Definition: HtmlParserTest.php:30
‪TYPO3\CMS\Core\Html\HtmlParser
Definition: HtmlParser.php:27
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\prefixResourcePathTest
‪prefixResourcePathTest(string $content, string $prefix, string $expectedResult)
Definition: HtmlParserTest.php:810
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\getFirstTagNameDataProvider
‪array getFirstTagNameDataProvider()
Definition: HtmlParserTest.php:506
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\prefixResourcePathDataProvider
‪prefixResourcePathDataProvider()
Definition: HtmlParserTest.php:734
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\cDataWillRemainUnmodifiedDataProvider
‪array cDataWillRemainUnmodifiedDataProvider()
Definition: HtmlParserTest.php:39
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\getFirstTag
‪getFirstTag(string $str, string $expected)
Definition: HtmlParserTest.php:496
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\globalNestingCorrectlyRemovesInvalidTags
‪globalNestingCorrectlyRemovesInvalidTags(string $content, string $expectedResult)
Definition: HtmlParserTest.php:316
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\removeFirstAndLastTag
‪removeFirstAndLastTag(string $str, string $expectedResult)
Definition: HtmlParserTest.php:623
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\globalNestingCorrectlyRemovesInvalidTagsDataProvider
‪static array globalNestingCorrectlyRemovesInvalidTagsDataProvider()
Definition: HtmlParserTest.php:284
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\stripEmptyTagsKeepsConfiguredTagsDataProvider
‪array stripEmptyTagsKeepsConfiguredTagsDataProvider()
Definition: HtmlParserTest.php:398
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\htmlWithDifferentSingleTagsDataProvider
‪static htmlWithDifferentSingleTagsDataProvider()
Definition: HtmlParserTest.php:168
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest
Definition: HtmlParserTest.php:27
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\getFirstTagName
‪getFirstTagName(string $str, bool $preserveCase, string $expected)
Definition: HtmlParserTest.php:568
‪TYPO3\CMS\Core\Tests\Unit\Html
Definition: HtmlParserTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\stripEmptyTagsDataProvider
‪array stripEmptyTagsDataProvider()
Definition: HtmlParserTest.php:676
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\emptyTagsDataProvider
‪array emptyTagsDataProvider()
Definition: HtmlParserTest.php:328
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\stripEmptyTags
‪stripEmptyTags(bool $stripOn, $tagList, bool $treatNonBreakingSpaceAsEmpty, string $content, string $expectedResult)
Definition: HtmlParserTest.php:375
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\tagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured
‪tagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured(string $content, string $expectedResult)
Definition: HtmlParserTest.php:204
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\getTagAttributes
‪getTagAttributes(string $tag, array $expectedResult)
Definition: HtmlParserTest.php:668
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\$subject
‪HtmlParser $subject
Definition: HtmlParserTest.php:28
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\getTagAttributesDataProvider
‪array getTagAttributesDataProvider()
Definition: HtmlParserTest.php:631
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\parseConfigAndCleanHtml
‪string parseConfigAndCleanHtml(array $tsConfig, string $content)
Definition: HtmlParserTest.php:450
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\localNestingCorrectlyRemovesInvalidTagsDataProvider
‪static array localNestingCorrectlyRemovesInvalidTagsDataProvider()
Definition: HtmlParserTest.php:238
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\getFirstTagDataProvider
‪array getFirstTagDataProvider()
Definition: HtmlParserTest.php:461
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\removeFirstAndLastTagDataProvider
‪array removeFirstAndLastTagDataProvider()
Definition: HtmlParserTest.php:576
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\rmTagIfNoAttribIsConfiguredDoesNotChangeNestingType
‪rmTagIfNoAttribIsConfiguredDoesNotChangeNestingType()
Definition: HtmlParserTest.php:221
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\rawStripEmptyTagsTest
‪rawStripEmptyTagsTest(string $content, string $tagList, bool $treatNonBreakingSpaceAsEmpty, string $expectedResult)
Definition: HtmlParserTest.php:722
‪TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\splitIntoBlockDataProvider
‪array splitIntoBlockDataProvider()
Definition: HtmlParserTest.php:66