#65396 closed defect (bug) (reported-upstream)
Blocks: Add missing esc_url() to href output in post-author-name and post-date block renderers
| Reported by: | thisismyurl | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Editor | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
Description
The post-author-name and post-date block render functions output URLs
directly into href attributes without esc_url().
post-author-name.php line 35: get_author_posts_url() is passed raw into
the sprintf href placeholder.
post-date.php line 87: get_the_permalink() is passed raw into the sprintf
href placeholder. This line also uses %1s/%2s format specifiers instead of
the positional %1$s/%2$s used consistently in all sibling block renderers.
Both sibling files (post-author.php, comment-author-name.php, post-title.php)
wrap their href values with esc_url(). These two files were missed.
Fix: wrap get_author_posts_url() and get_the_permalink() with esc_url() in
both files, and update the format specifiers in post-date.php for consistency.
Change History (5)
This ticket was mentioned in PR #12061 on WordPress/wordpress-develop by @thisismyurl.
4 months ago
#1
#2
@
4 months ago
- Keywords close move-to-github added; needs-testing removed
- Version trunk
Hi and thanks for the report!
These will need to be fixed in the plugin first. Could you open a Gutenberg PR (and/or an issue)?
#3
@
4 months ago
Hi @sabernhardt,
Thanks for pointing that out. I've gone ahead and opened a Gutenberg PR for this: https://github.com/WordPress/gutenberg/pull/78912
When you have a chance, could you please take a look? Thank You
#4
@
4 months ago
- Keywords close move-to-github removed
- Milestone Awaiting Review
- Resolution → reported-upstream
- Status new → closed
Thanks for opening the PR
@thisismyurl commented on PR #12061:
3 months ago
#5
Closing this out. Trac #65396 was closed as reported-upstream since these renderers are synced from the Gutenberg block-library packages, and Gutenberg trunk now carries the fix: both post-author-name and post-date wrap their href values with esc_url() and use the positional %1$s specifiers. The change will reach core through the normal package sync, so there is nothing left for this PR to do.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
## Summary
get_author_posts_url()withesc_url()inpost-author-name.php— it was passed directly into the sprintf href placeholderget_the_permalink()withesc_url()inpost-date.php— same issue, plus corrects%1s/%2sto%1$s/%2$sto match the positional format specifiers used in all sibling block rendererspost-author.php,comment-author-name.php, andpost-title.phpall wrap their href values withesc_url(). These two files were missed.## Testing
php -l src/wp-includes/blocks/post-author-name.phpphp -l src/wp-includes/blocks/post-date.phpvendor/bin/phpcs --standard=phpcs.xml.dist src/wp-includes/blocks/post-author-name.php src/wp-includes/blocks/post-date.phpTrac ticket: https://core.trac.wordpress.org/ticket/65396
(full disclosure, I used AI help with the testing and tweaks - Christopher)