Skip to content

Commit 4ddc905

Browse files
committed
Abilities API: Stop HTML-escaping the ability name in WP_Error messages
Ability names are pattern-validated at registration, so `esc_html()` on them is always a no-op. Drop it from the `WP_Error` messages, which are commonly serialized to JSON where the escaping would be incorrect. Follow-up to [62398]. See #64311. git-svn-id: https://develop.svn.wordpress.org/trunk@62401 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 600a8ba commit 4ddc905

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/wp-includes/abilities-api/class-wp-ability.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ protected function invoke_callback( callable $callback, $input = null ) {
561561
sprintf(
562562
/* translators: 1: Ability name, 2: Exception message. */
563563
__( 'Ability "%1$s" callback threw an exception: %2$s' ),
564-
esc_html( $this->name ),
564+
$this->name,
565565
esc_html( $e->getMessage() )
566566
)
567567
);
@@ -590,7 +590,7 @@ public function check_permissions( $input = null ) {
590590
return new WP_Error(
591591
'ability_invalid_permission_callback',
592592
/* translators: %s ability name. */
593-
sprintf( __( 'Ability "%s" does not have a valid permission callback.' ), esc_html( $this->name ) )
593+
sprintf( __( 'Ability "%s" does not have a valid permission callback.' ), $this->name )
594594
);
595595
}
596596

@@ -638,7 +638,7 @@ protected function do_execute( $input = null ) {
638638
$result = new WP_Error(
639639
'ability_invalid_execute_callback',
640640
/* translators: %s ability name. */
641-
sprintf( __( 'Ability "%s" does not have a valid execute callback.' ), esc_html( $this->name ) )
641+
sprintf( __( 'Ability "%s" does not have a valid execute callback.' ), $this->name )
642642
);
643643
} else {
644644
$result = $this->invoke_callback( $this->execute_callback, $input );
@@ -783,7 +783,7 @@ public function execute( $input = null ) {
783783
return new WP_Error(
784784
'ability_invalid_permissions',
785785
/* translators: %s ability name. */
786-
sprintf( __( 'Ability "%s" does not have necessary permission.' ), esc_html( $this->name ) )
786+
sprintf( __( 'Ability "%s" does not have necessary permission.' ), $this->name )
787787
);
788788
}
789789

0 commit comments

Comments
 (0)