Opened 2 weeks ago
Last modified 12 days ago
#62522 reopened defect (bug)
Whitespace can trip up `WP_Interactivity_API::_process_directives()` when there is a `core/button` `text` block binding
Reported by: | wongjn | Owned by: | jonsurrell |
---|---|---|---|
Milestone: | 6.7.2 | Priority: | normal |
Severity: | normal | Version: | 6.6 |
Component: | HTML API | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
Steps to reproduce
- Set
WP_DEBUG
totrue
inwp-config.php
. - Install clean WordPress 6.7.1.
- Activate Twenty Twenty-Four theme.
- Replace
/wp-content/themes/twentytwentyfour/templates/single.html
with:<!-- wp:query {"queryId":0,"query":{"perPage":10,"pages":"0","offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false,"parents":[],"format":[]},"enhancedPagination":true,"layout":{"type":"constrained"}} --> <div class="wp-block-query"> <!-- wp:post-template {"layout":{"type":"default","columnCount":3}} --> <!-- wp:buttons --> <div class="wp-block-buttons"><!-- wp:button {"metadata":{"bindings":{"text":{"source":"core/post-meta","args":{"key":"foo"}}}}} --> <div class="wp-block-button"><a class="wp-block-button__link wp-element-button">Get Tickets</a></div> <!-- /wp:button --> </div> <!-- /wp:buttons --> <!-- /wp:post-template --> </div> <!-- /wp:query -->
- Append the following to
/wp-content/themes/twentytwentyfour/functions.php
:function _test() { $args = array( 'type' => 'string', 'single' => true, 'sanitize_callback' => '', 'show_in_rest' => true, 'revisions_enabled' => true, ); register_post_meta( 'post', 'foo', $args ); update_post_meta(1, 'foo', 'test' ); } add_action( 'init', '_test' );
- Navigate to
/index.php?p=1
(the Hello World post) in your browser. - Notice no errors.
- Replace
/wp-content/themes/twentytwentyfour/templates/single.html
with:<!-- wp:query {"queryId":0,"query":{"perPage":10,"pages":"0","offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false,"parents":[],"format":[]},"enhancedPagination":true,"layout":{"type":"constrained"}} --> <div class="wp-block-query"> <!-- wp:post-template {"layout":{"type":"default","columnCount":3}} --> <!-- wp:buttons --> <div class="wp-block-buttons"> <!-- wp:button {"metadata":{"bindings":{"text":{"source":"core/post-meta","args":{"key":"foo"}}}}} --> <div class="wp-block-button"><a class="wp-block-button__link wp-element-button">Get Tickets</a></div> <!-- /wp:button --> </div> <!-- /wp:buttons --> <!-- /wp:post-template --> </div> <!-- /wp:query -->
- Navigate to
/index.php?p=1
(the Hello World post) in your browser. - Notice an error displayed:
Notice: Function WP_Interactivity_API::_process_directives was called <strong>incorrectly</strong>. Interactivity directives failed to process in "" due to a missing "LI" end tag. Please see <a href="https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 6.6.0.) in /path/to/wordpress/wp-includes/functions.php on line 6114
Other remarkables
- When the error is displayed, the markup has some HTML in uppercase:
<DIV class="wp-block-button"><a class="wp-block-button__link wp-element-button">test</a></DIV>
- Any amount of newline/whitespace seems to cause the error:
<!-- wp:query {"queryId":0,"query":{"perPage":10,"pages":"0","offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false,"parents":[],"format":[]},"enhancedPagination":true,"layout":{"type":"constrained"}} --> <div class="wp-block-query"> <!-- wp:post-template {"layout":{"type":"default","columnCount":3}} --> <!-- wp:buttons --> <div class="wp-block-buttons"> <!-- wp:button {"metadata":{"bindings":{"text":{"source":"core/post-meta","args":{"key":"foo"}}}}} --> <div class="wp-block-button"><a class="wp-block-button__link wp-element-button">Get Tickets</a></div> <!-- /wp:button --> </div> <!-- /wp:buttons --> <!-- /wp:post-template --> </div> <!-- /wp:query -->
- Including the same snippet from _Copy All Blocks_ command in the editor, but with a newline before the opening
core/button
comment:<!-- wp:query {"queryId":0,"query":{"perPage":10,"pages":"0","offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false,"parents":[],"format":[]},"enhancedPagination":true,"layout":{"type":"constrained"}} --> <div class="wp-block-query"><!-- wp:post-template {"layout":{"type":"default","columnCount":3}} --> <!-- wp:buttons {"layout":{"type":"flex"}} --> <div class="wp-block-buttons"> <!-- wp:button {"metadata":{"bindings":{"text":{"source":"core/post-meta","args":{"key":"foo"}}}}} --> <div class="wp-block-button"><a class="wp-block-button__link wp-element-button">Get Tickets</a></div> <!-- /wp:button --></div> <!-- /wp:buttons --> <!-- /wp:post-template --></div> <!-- /wp:query -->
Change History (8)
This ticket was mentioned in PR #7893 on WordPress/wordpress-develop by @santosguillamot.
13 days ago
#1
- Keywords has-patch added
This ticket was mentioned in PR #7897 on WordPress/wordpress-develop by @jonsurrell.
13 days ago
#3
- Keywords has-unit-tests added
Ensure uppercase tag names are matched correctly by the tag processor.
Ticket 62522 describes an issue where a whitespace-prefixed tag was causing problems. With the help of @SantosGuillamot and @cbravobernal, this was narrowed down to an uppercase open tag name prefixed by whitespace not being found in the tag processor.
There was a missing "D" in the character list used by strspn
to find tag openers, causing tags starting with D
to be skipped by the tag processor in some circumstances.
Add tests to ensure variations of uppper and lowercase tag names openers and closers are recognized.
This only appears in rare cases because the tag name must appear in the correct position (preceded by whitespace) and must start with an uppercase D
. Casing is not relevant for tag names, and most tag names are lowercase in the wild.
Trac ticket: https://core.trac.wordpress.org/ticket/62522
Closes https://github.com/WordPress/wordpress-develop/pull/7893 (supersedes).
#4
@
13 days ago
- Component changed from Interactivity API to HTML API
- Milestone changed from 6.8 to 6.7.2
- Owner set to jonsurrell
- Status changed from new to assigned
I'm changing the milestone to 6.7.2, I'd like https://github.com/WordPress/wordpress-develop/pull/7897 to be considered for inclusion.
@cbravobernal commented on PR #7897:
12 days ago
#6
Committed in https://core.trac.wordpress.org/changeset/59464
@cbravobernal commented on PR #7893:
12 days ago
#7
Superseeded by https://github.com/WordPress/wordpress-develop/pull/7897
Trac ticket: https://core.trac.wordpress.org/ticket/62522
Fixes a bug where processing the button block with bindings returns the HTML wrapper DIV in uppercase, which breaks other processing, like the Interactivity API directives.