Make WordPress Core

Ticket #43177: 43177.2.patch

File 43177.2.patch, 2.5 KB (added by jaswrks, 7 years ago)

Take 2, use '' === trim(

  • src/wp-admin/includes/ajax-actions.php

     
    11461146                wp_die( __( 'Sorry, you must be logged in to reply to a comment.' ) );
    11471147        }
    11481148
    1149         if ( '' == $comment_content ) {
     1149        if ( '' === trim( $comment_content ) ) {
    11501150                wp_die( __( 'ERROR: please type a comment.' ) );
    11511151        }
    11521152
  • src/wp-includes/class-wp-xmlrpc-server.php

     
    37193719
    37203720                if ( isset( $content_struct['content'] ) ) {
    37213721                        $comment_content = $content_struct['content'];
     3722
     3723                        if ( '' === trim( $comment_content ) ) {
     3724                                return new IXR_Error( 403, __( 'Invalid comment content.' ) );
     3725                        }
    37223726                }
    37233727
    37243728                if ( isset( $content_struct['author'] ) ) {
     
    38233827                        return new IXR_Error( 403, __( 'Sorry, comments are closed for this item.' ) );
    38243828                }
    38253829
    3826                 if ( empty( $content_struct['content'] ) ) {
     3830                if ( empty( $content_struct['content'] ) || '' === trim( $content_struct['content'] ) ) {
    38273831                        return new IXR_Error( 403, __( 'Comment is required.' ) );
    38283832                }
    38293833
  • src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

     
    504504                 * Do not allow a comment to be created with missing or empty
    505505                 * comment_content. See wp_handle_comment_submission().
    506506                 */
    507                 if ( empty( $prepared_comment['comment_content'] ) ) {
     507                if ( empty( $prepared_comment['comment_content'] ) || '' === trim( $prepared_comment['comment_content'] ) ) {
    508508                        return new WP_Error( 'rest_comment_content_invalid', __( 'Invalid comment content.' ), array( 'status' => 400 ) );
    509509                }
    510510
     
    707707                                return $prepared_args;
    708708                        }
    709709
    710                         if ( isset( $prepared_args['comment_content'] ) && empty( $prepared_args['comment_content'] ) ) {
     710                        if ( isset( $prepared_args['comment_content'] ) && '' === trim( $prepared_args['comment_content'] ) ) {
    711711                                return new WP_Error( 'rest_comment_content_invalid', __( 'Invalid comment content.' ), array( 'status' => 400 ) );
    712712                        }
    713713