-
Notifications
You must be signed in to change notification settings - Fork 3.6k
HTML API: Ensure form feed is recognized as close tag name terminator #12936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
65c6ad5
8536658
95fc0e0
c80fb05
c5914e9
94536a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2369,6 +2369,54 @@ public static function data_script_tag(): Generator { | |||||
| yield 'Script tag double-escaped with <script\r' => array( "<script><!--<script\r</script>", false ); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Ensures that tag-name-terminating characters close RCDATA and RAWTEXT elements. | ||||||
| * | ||||||
| * @ticket 65372 | ||||||
| * | ||||||
| * @dataProvider data_rcdata_and_rawtext_tag_name_terminators | ||||||
| * | ||||||
| * @param string $tag_name The RCDATA or RAWTEXT tag name. | ||||||
| * @param string $tag_name_terminator The tag-name-terminating character. | ||||||
| */ | ||||||
| public function test_rcdata_and_rawtext_end_tags_accept_tag_name_terminators( string $tag_name, string $tag_name_terminator ): void { | ||||||
| $end_tag_closer = '>' === $tag_name_terminator ? '' : '>'; | ||||||
| $processor = new WP_HTML_Tag_Processor( "<{$tag_name}>content</{$tag_name}{$tag_name_terminator}{$end_tag_closer}<div>" ); | ||||||
|
|
||||||
| $this->assertTrue( $processor->next_token(), "Expected to find complete {$tag_name} tag." ); | ||||||
| $this->assertSame( strtoupper( $tag_name ), $processor->get_tag() ); | ||||||
| $this->assertSame( 'content', $processor->get_modifiable_text() ); | ||||||
| $this->assertTrue( $processor->next_tag( 'DIV' ), "Expected to find DIV after the {$tag_name} element." ); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Provides every RCDATA and RAWTEXT tag with every tag-name-terminating character. | ||||||
| * | ||||||
| * @return Generator<string, array{string, string}> Test cases. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| */ | ||||||
| public static function data_rcdata_and_rawtext_tag_name_terminators(): Generator { | ||||||
| foreach ( array( 'IFRAME', 'NOEMBED', 'NOFRAMES', 'STYLE', 'XMP', 'TEXTAREA', 'TITLE' ) as $tag_name ) { | ||||||
| foreach ( self::data_tag_name_terminators() as $terminator_name => $terminator_data ) { | ||||||
| yield "{$tag_name} + {$terminator_name}" => array( strtolower( $tag_name ), $terminator_data[0] ); | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Provides tag-name-terminating characters. | ||||||
| * | ||||||
| * @return Generator<string, array{string}> Test cases. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| */ | ||||||
| public static function data_tag_name_terminators(): Generator { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, nice. I didn't realize you could use a generator as a data provider. |
||||||
| yield 'SPACE' => array( ' ' ); | ||||||
| yield 'TAB' => array( "\t" ); | ||||||
| yield 'LINE FEED' => array( "\n" ); | ||||||
| yield 'FORM FEED' => array( "\f" ); | ||||||
| yield 'CARRIAGE RETURN' => array( "\r" ); | ||||||
| yield 'SOLIDUS' => array( '/' ); | ||||||
| yield 'GREATER-THAN SIGN' => array( '>' ); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Invalid tag names are comments on tag closers. | ||||||
| * | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.