Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb36b3a6

Browse files
[HtmlSanitizer] Remove MastermindsParser and add $context arg to ParserInterface::parse()
1 parentace7825 commitb36b3a6

File tree

9 files changed

+17
-100
lines changed

9 files changed

+17
-100
lines changed

‎UPGRADE-8.0.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ FrameworkBundle
171171
* Remove the`validation.cache` option
172172
* Remove`TranslationUpdateCommand` in favor of`TranslationExtractCommand`
173173

174+
HtmlSanitizer
175+
-------------
176+
177+
* Remove`MastermindsParser`; use`NativeParser` instead
178+
* Add argument`$context` to`ParserInterface::parse()`
179+
174180
HttpFoundation
175181
--------------
176182

‎src/Symfony/Component/HtmlSanitizer/CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
8.0
5+
---
6+
7+
* Remove`MastermindsParser`; use`NativeParser` instead
8+
* Add argument`$context` to`ParserInterface::parse()`
9+
410
7.4
511
---
612

‎src/Symfony/Component/HtmlSanitizer/HtmlSanitizer.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespaceSymfony\Component\HtmlSanitizer;
1313

14-
useSymfony\Component\HtmlSanitizer\Parser\MastermindsParser;
1514
useSymfony\Component\HtmlSanitizer\Parser\NativeParser;
1615
useSymfony\Component\HtmlSanitizer\Parser\ParserInterface;
1716
useSymfony\Component\HtmlSanitizer\Reference\W3CReference;
@@ -35,7 +34,7 @@ public function __construct(
3534
?ParserInterface$parser =null,
3635
) {
3736
$this->config =$config;
38-
$this->parser =$parser ??(\PHP_VERSION_ID <80400 ?newMastermindsParser() :newNativeParser());
37+
$this->parser =$parser ??newNativeParser();
3938
}
4039

4140
publicfunctionsanitize(string$input):string

‎src/Symfony/Component/HtmlSanitizer/Parser/MastermindsParser.php‎

Lines changed: 0 additions & 34 deletions
This file was deleted.

‎src/Symfony/Component/HtmlSanitizer/Parser/NativeParser.php‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@
1616
*/
1717
finalclass NativeParserimplements ParserInterface
1818
{
19-
publicfunction__construct()
20-
{
21-
if (\PHP_VERSION_ID <80400) {
22-
thrownew \LogicException(self::class.' requires PHP 8.4 or higher.');
23-
}
24-
}
25-
2619
publicfunctionparse(string$html,string$context ='body'): ?\Dom\Node
2720
{
2821
$document = @\Dom\HTMLDocument::createFromString(\sprintf('<!DOCTYPE html><%s>%s</%1$s>',$context,$html));

‎src/Symfony/Component/HtmlSanitizer/Parser/ParserInterface.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ interface ParserInterface
2525
*
2626
* @param string $context The name of the context element in which the HTML is parsed
2727
*/
28-
publicfunctionparse(string$html/*, string $context = 'body' */):\Dom\Node|\DOMNode|null;
28+
publicfunctionparse(string$html,string$context ='body'):\Dom\Node|\DOMNode|null;
2929
}

‎src/Symfony/Component/HtmlSanitizer/Tests/HtmlSanitizerAllTest.php‎

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,8 @@ public static function provideSanitizeHead()
6464
}
6565

6666
#[DataProvider('provideSanitizeBody')]
67-
publicfunctiontestSanitizeBody(string$input,string$expected, ?string$legacyExpected =null)
67+
publicfunctiontestSanitizeBody(string$input,string$expected)
6868
{
69-
if (\PHP_VERSION_ID <80400) {
70-
$expected =$legacyExpected ??$expected;
71-
}
7269
$this->assertSame($expected,$this->createSanitizer()->sanitize($input));
7370
}
7471

@@ -87,7 +84,6 @@ public static function provideSanitizeBody()
8784
[
8885
'< Hello',
8986
'&lt; Hello',
90-
' Hello',
9187
],
9288
[
9389
'Lorem & Ipsum',
@@ -132,7 +128,6 @@ public static function provideSanitizeBody()
132128
[
133129
'<<a href="#"diff-7e982ccdd41248f694de5fa360040da39bd8ad812866f11d06122034efa3e936-134-130-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">134
130
'&lt;<a>a href&#61;&#34;#"diff-7e982ccdd41248f694de5fa360040da39bd8ad812866f11d06122034efa3e936-135-130-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">135
-
'<a>a href&#61;&#34;#"diff-7e982ccdd41248f694de5fa360040da39bd8ad812866f11d06122034efa3e936-136-131-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">136
131
],
137132
[
138133
'<a href="#"diff-7e982ccdd41248f694de5fa360040da39bd8ad812866f11d06122034efa3e936-168-163-0" data-selected="false" role="gridcell" tabindex="-1" valign="top" colSpan="4">
@@ -169,12 +164,10 @@ public static function provideSanitizeBody()
169164
[
170165
'<<img src="#"diff-7e982ccdd41248f694de5fa360040da39bd8ad812866f11d06122034efa3e936-171-166-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">171
166
'&lt;<img />iframe src&#61;&#34;#"diff-7e982ccdd41248f694de5fa360040da39bd8ad812866f11d06122034efa3e936-172-166-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">172
-
'<img />iframe src&#61;&#34;#"diff-7e982ccdd41248f694de5fa360040da39bd8ad812866f11d06122034efa3e936-173-167-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">173
167
],
174168
[
175169
'<<img src="#"diff-7e982ccdd41248f694de5fa360040da39bd8ad812866f11d06122034efa3e936-176-170-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">176
170
'&lt;<img />img src&#61;&#34;#"diff-7e982ccdd41248f694de5fa360040da39bd8ad812866f11d06122034efa3e936-177-170-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">177
-
'<img />img src&#61;&#34;#"diff-7e982ccdd41248f694de5fa360040da39bd8ad812866f11d06122034efa3e936-178-171-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">178
171
],
179172
[
180173
'<IMG SRC="#"diff-7e982ccdd41248f694de5fa360040da39bd8ad812866f11d06122034efa3e936-218-211-0" data-selected="false" role="gridcell" tabindex="-1" valign="top" colSpan="4">
@@ -219,12 +212,10 @@ public static function provideSanitizeBody()
219212
[
220213
'<IMG SRC=&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041>',
221214
'<img />',
222-
'<img src="&amp;#0000106&amp;#0000097&amp;#0000118&amp;#0000097&amp;#0000115&amp;#0000099&amp;#0000114&amp;#0000105&amp;#0000112&amp;#0000116&amp;#0000058&amp;#0000097&amp;#0000108&amp;#0000101&amp;#0000114&amp;#0000116&amp;#0000040&amp;#0000039&amp;#0000088&amp;#0000083&amp;#0000083&amp;#0000039&amp;#0000041" />',
223215
],
224216
[
225217
'<IMG SRC=&#x6A&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A&#x61&#x6C&#x65&#x72&#x74&#x28&#x27&#x58&#x53&#x53&#x27&#x29>',
226218
'<img />',
227-
'<img src="&amp;#x6A&amp;#x61&amp;#x76&amp;#x61&amp;#x73&amp;#x63&amp;#x72&amp;#x69&amp;#x70&amp;#x74&amp;#x3A&amp;#x61&amp;#x6C&amp;#x65&amp;#x72&amp;#x74&amp;#x28&amp;#x27&amp;#x58&amp;#x53&amp;#x53&amp;#x27&amp;#x29" />',
228219
],
229220
[
230221
'<IMG DYNSRC="#"diff-7e982ccdd41248f694de5fa360040da39bd8ad812866f11d06122034efa3e936-530-521-0" data-selected="false" role="gridcell" tabindex="-1" valign="top" colSpan="4">
@@ -531,7 +522,6 @@ public static function provideSanitizeBody()
531522
[
532523
'<table>Lorem ipsum</table>',
533524
'Lorem ipsum<table></table>',
534-
'<table>Lorem ipsum</table>',
535525
],
536526
[
537527
'<ul>Lorem ipsum</ul>',
@@ -545,12 +535,8 @@ public static function provideSanitizeBody()
545535
}
546536

547537
#[DataProvider('provideSanitizeTable')]
548-
publicfunctiontestSanitizeTable(string$input,string$expected, ?string$legacyExpected =null)
538+
publicfunctiontestSanitizeTable(string$input,string$expected)
549539
{
550-
if (\PHP_VERSION_ID <80400) {
551-
$expected =$legacyExpected ??$expected;
552-
}
553-
554540
$this->assertSame($expected,$this->createSanitizer()->sanitizeFor('table',$input));
555541
}
556542

@@ -564,32 +550,26 @@ public static function provideSanitizeTable(): iterable
564550
[
565551
'<tbody>Lorem ipsum</tbody>',
566552
'<tbody></tbody>',
567-
'<tbody>Lorem ipsum</tbody>',
568553
],
569554
[
570555
'<td>Lorem ipsum</td>',
571556
'<tbody><tr><td>Lorem ipsum</td></tr></tbody>',
572-
'<td>Lorem ipsum</td>',
573557
],
574558
[
575559
'<tfoot>Lorem ipsum</tfoot>',
576560
'<tfoot></tfoot>',
577-
'<tfoot>Lorem ipsum</tfoot>',
578561
],
579562
[
580563
'<thead>Lorem ipsum</thead>',
581564
'<thead></thead>',
582-
'<thead>Lorem ipsum</thead>',
583565
],
584566
[
585567
'<th>Lorem ipsum</th>',
586568
'<tbody><tr><th>Lorem ipsum</th></tr></tbody>',
587-
'<th>Lorem ipsum</th>',
588569
],
589570
[
590571
'<tr>Lorem ipsum</tr>',
591572
'<tbody><tr></tr></tbody>',
592-
'<tr>Lorem ipsum</tr>',
593573
],
594574
];
595575
}

‎src/Symfony/Component/HtmlSanitizer/Tests/Parser/MastermindsParserTest.php‎

Lines changed: 0 additions & 31 deletions
This file was deleted.

‎src/Symfony/Component/HtmlSanitizer/composer.json‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
"require": {
1919
"php":">=8.4",
2020
"ext-dom":"*",
21-
"league/uri":"^6.5|^7.0",
22-
"masterminds/html5":"^2.7.2",
23-
"symfony/deprecation-contracts":"^2.5|^3"
21+
"league/uri":"^6.5|^7.0"
2422
},
2523
"autoload": {
2624
"psr-4": {"Symfony\\Component\\HtmlSanitizer\\":"" },

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp