From 8f154f244200983748faf836989df39f9a8daccd Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Mon, 5 Oct 2026 22:04:13 +0530 Subject: [PATCH 1/7] Posts: Improve display of post titles containing HTML in the admin. Add wp_kses_post_title() and use it for admin title output instead of esc_html(), allowing a subset of inline formatting tags while stripping unsafe markup. Strip tags for aria-labels and row action strings. Fixes #66244. --- src/wp-admin/comment.php | 4 +- src/wp-admin/edit-form-comment.php | 4 +- .../includes/class-wp-comments-list-table.php | 4 +- .../includes/class-wp-media-list-table.php | 7 ++-- .../includes/class-wp-posts-list-table.php | 14 +++++-- src/wp-admin/includes/dashboard.php | 6 +-- src/wp-admin/includes/template.php | 3 +- src/wp-includes/post-template.php | 25 ++++++++++++ .../phpunit/tests/admin/wpPostsListTable.php | 39 +++++++++++++++++++ tests/phpunit/tests/post/wpKsesPostTitle.php | 39 +++++++++++++++++++ 10 files changed, 128 insertions(+), 17 deletions(-) create mode 100644 tests/phpunit/tests/post/wpKsesPostTitle.php diff --git a/src/wp-admin/comment.php b/src/wp-admin/comment.php index ed93797a64faf..28e8df62e9fad 100644 --- a/src/wp-admin/comment.php +++ b/src/wp-admin/comment.php @@ -205,9 +205,9 @@ $post_id = $comment->comment_post_ID; if ( current_user_can( 'edit_post', $post_id ) ) { $post_link = ""; - $post_link .= esc_html( get_the_title( $post_id ) ) . ''; + $post_link .= wp_kses_post_title( get_the_title( $post_id ) ) . ''; } else { - $post_link = esc_html( get_the_title( $post_id ) ); + $post_link = wp_kses_post_title( get_the_title( $post_id ) ); } echo $post_link; diff --git a/src/wp-admin/edit-form-comment.php b/src/wp-admin/edit-form-comment.php index 375dd61ad955e..6f6da27c49f30 100644 --- a/src/wp-admin/edit-form-comment.php +++ b/src/wp-admin/edit-form-comment.php @@ -184,9 +184,9 @@ $post_id = $comment->comment_post_ID; if ( current_user_can( 'edit_post', $post_id ) ) { $post_link = ""; - $post_link .= esc_html( get_the_title( $post_id ) ) . ''; + $post_link .= wp_kses_post_title( get_the_title( $post_id ) ) . ''; } else { - $post_link = esc_html( get_the_title( $post_id ) ); + $post_link = wp_kses_post_title( get_the_title( $post_id ) ); } ?> diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index 2b927a7f81a6a..0d3b8698ff94f 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -1121,9 +1121,9 @@ public function column_response( $comment ) { if ( current_user_can( 'edit_post', $post->ID ) ) { $post_link = ""; - $post_link .= esc_html( get_the_title( $post->ID ) ) . ''; + $post_link .= wp_kses_post_title( get_the_title( $post->ID ) ) . ''; } else { - $post_link = esc_html( get_the_title( $post->ID ) ); + $post_link = wp_kses_post_title( get_the_title( $post->ID ) ); } echo '