Make WordPress Core

Ticket #17159: wp-comments-post.diff

File wp-comments-post.diff, 835 bytes (added by niallkennedy, 16 years ago)

Return a 400 response if no comment_post_ID provided.

  • wp-comments-post.php

     
    55 * @package WordPress
    66 */
    77
    8 if ( 'POST' != $_SERVER['REQUEST_METHOD'] ) {
     8if ( 'POST' !== $_SERVER['REQUEST_METHOD'] ) {
     9        header('HTTP/1.1 405 Method Not Allowed');
    910        header('Allow: POST');
    10         header('HTTP/1.1 405 Method Not Allowed');
    1111        header('Content-Type: text/plain');
    1212        exit;
    1313}
    … …  
    1919
    2020$comment_post_ID = isset($_POST['comment_post_ID']) ? (int) $_POST['comment_post_ID'] : 0;
    2121
     22if ( $comment_post_ID === 0 )
     23        wp_die( __( 'A comment must be associated with a WordPress post id.' ), __( 'Invalid request' ), array( 'response'=>400 ) );
     24
    2225$post = get_post($comment_post_ID);
    2326
    2427if ( empty($post->comment_status) ) {