[wp-trac] [WordPress Trac] #57852: HTML API: Support RCData and Script tag closers
WordPress Trac
noreply at wordpress.org
Mon Mar 6 18:39:31 UTC 2023
#57852: HTML API: Support RCData and Script tag closers
-------------------------------------------------+-------------------------
Reporter: zieladam | Owner:
| hellofromTonya
Type: defect (bug) | Status: reviewing
Priority: normal | Milestone: 6.2
Component: General | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests has- | Focuses:
testing-info |
-------------------------------------------------+-------------------------
Changes (by hellofromTonya):
* keywords: has-patch has-unit-tests => has-patch has-unit-tests has-
testing-info
Comment:
== Test Report
Patch tested: https://github.com/WordPress/wordpress-develop/pull/4164
=== Steps to Reproduce or Test
1. Create a must-use plugins directory in `wp-content/mu-plugins/`.
2. Add a new `test.php` file in that directory.
3. Copy the following code into the test file:
{{{#!php
<?php
add_action( 'init', function() {
$p = new WP_HTML_Tag_Processor( '<script>ABC</script><p>Some
content</p>' );
$p->next_tag();
$p->next_tag( array( 'tag_closers' => 'visit' ) );
$tag = $p->get_tag(); // Should be 'SCRIPT'
echo "<p style='margin:30px;font-size:50px'>$tag</p>";
exit;
});
}}}
4. Refresh the browser to view the site. 🐞 Bug occurs.
=== Expected Results
When testing a patch to validate it works as expected:
- ✅ It should display: `SCRIPT`
When reproducing a bug:
- ❌ It'll display: `P`
=== Environment
* Browser: Chrome
* Localhost: wp-env (Docker)
* OS: macOS
* Plugins: none
* Theme: TT3
* WordPress: trunk
==== Actual Results
When reproducing a bug/defect:
- ❌ Yes, can confirm that it finds `P` instead of `SCRIPT`.
When testing the bugfix patch:
- ✅ Yes, can confirm that when applying the patch, it now finds the
closer tag, i.e. `SCRIPT`.
===== Automated Tests
When running
{{{
npm run test:php -- --group html-api
}}}
with the patch, the results are ❌:
{{{
..............................................F................ 63 / 164
( 38%)
............................................................... 126 / 164
( 76%)
...................................... 164 / 164
(100%)
Time: 00:01.991, Memory: 150.50 MB
There was 1 failure:
1)
Tests_HtmlApi_wpHtmlTagProcessor::test_next_tag_should_stop_on_rcdata_and_script_tag_closers_when_requested
Did not find the </script> tag closer
Failed asserting that false is true.
}}}
This is expected and reproduces the bug.
After applying the patch, the tests pass ✅
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57852#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list