diff --git a/features/comment.feature b/features/comment.feature index 6fcbd88d4d..b0058297eb 100644 --- a/features/comment.feature +++ b/features/comment.feature @@ -249,3 +249,22 @@ Feature: Manage WordPress comments """ 0 """ + + Scenario: Make sure WordPress receives the slashed data it expects + When I run `wp comment create --comment_content='My\Comment' --porcelain` + Then save STDOUT as {COMMENT_ID} + + When I run `wp comment get {COMMENT_ID} --field=comment_content` + Then STDOUT should be: + """ + My\Comment + """ + + When I run `wp comment update {COMMENT_ID} --comment_content='My\New\Comment'` + Then STDOUT should not be empty + + When I run `wp comment get {COMMENT_ID} --field=comment_content` + Then STDOUT should be: + """ + My\New\Comment + """ diff --git a/php/commands/comment.php b/php/commands/comment.php index 56b1ad0b77..c153104a9e 100644 --- a/php/commands/comment.php +++ b/php/commands/comment.php @@ -58,6 +58,7 @@ public function __construct() { * Success: Created comment 932. */ public function create( $args, $assoc_args ) { + $assoc_args = wp_slash( $assoc_args ); parent::_create( $args, $assoc_args, function ( $params ) { if ( isset( $params['comment_post_ID'] ) ) { $post_id = $params['comment_post_ID']; @@ -96,6 +97,7 @@ public function create( $args, $assoc_args ) { * Success: Updated comment 123. */ public function update( $args, $assoc_args ) { + $assoc_args = wp_slash( $assoc_args ); parent::_update( $args, $assoc_args, function ( $params ) { if ( !wp_update_comment( $params ) ) { return new WP_Error( 'Could not update comment.' );