forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Comments: Validate new comments before and after comment data is filt…
…ered. This ensures that a Disallowed Comment Keys match will consistently send the comment to the Trash, by checking both the original unmodified comment data and the final filtered comment data. If the first check has already resulted in a `trash` or `spam` status, the second check is skipped as redundant. Follow-up to [2894], [3851], [48121], [48575]. Props cfinke, kbrownkd, thompsonsj, mi5t4n, devspace, chaion07, engahmeds3ed, SergeyBiryukov. Fixes #61827. git-svn-id: https://develop.svn.wordpress.org/trunk@59267 602fd350-edb4-49c9-b593-d223f7449a82
- Loading branch information
1 parent
815f0c3
commit 309ecbd
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -976,4 +976,41 @@ public function data_should_only_allow_replying_to_an_existing_parent_comment() | |
'a non-existent parent comment' => array( 'exists' => false ), | ||
); | ||
} | ||
|
||
public function test_disallowed_keys_match_gives_approved_status_of_trash() { | ||
$data = array( | ||
'comment_post_ID' => self::$post->ID, | ||
'comment' => 'Comment', | ||
'author' => 'Comment Author', | ||
'email' => '[email protected]', | ||
); | ||
|
||
update_option( 'disallowed_keys', "Comment\nfoo" ); | ||
|
||
$comment = wp_handle_comment_submission( $data ); | ||
|
||
$this->assertNotWPError( $comment ); | ||
$this->assertInstanceOf( 'WP_Comment', $comment ); | ||
$this->assertSame( 'trash', $comment->comment_approved ); | ||
} | ||
|
||
/** | ||
* @ticket 61827 | ||
*/ | ||
public function test_disallowed_keys_html_match_gives_approved_status_of_trash() { | ||
$data = array( | ||
'comment_post_ID' => self::$post->ID, | ||
'comment' => '<a href=http://example.com/>example</a>', | ||
'author' => 'Comment Author', | ||
'email' => '[email protected]', | ||
); | ||
|
||
update_option( 'disallowed_keys', "href=http\nfoo" ); | ||
|
||
$comment = wp_handle_comment_submission( $data ); | ||
|
||
$this->assertNotWPError( $comment ); | ||
$this->assertInstanceOf( 'WP_Comment', $comment ); | ||
$this->assertSame( 'trash', $comment->comment_approved ); | ||
} | ||
} |