Fire the check_admin_referer action on failure as well as success.

This enables things like logging nonce failures in the admin.

props markjaquith.
fixes #32207.


git-svn-id: https://develop.svn.wordpress.org/trunk@33017 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Helen Hou-Sandi 2015-07-01 03:36:58 +00:00
parent e5c4c584c0
commit cf9b82dd14

View File

@ -1091,10 +1091,6 @@ function check_admin_referer( $action = -1, $query_arg = '_wpnonce' ) {
$adminurl = strtolower(admin_url()); $adminurl = strtolower(admin_url());
$referer = strtolower(wp_get_referer()); $referer = strtolower(wp_get_referer());
$result = isset($_REQUEST[$query_arg]) ? wp_verify_nonce($_REQUEST[$query_arg], $action) : false; $result = isset($_REQUEST[$query_arg]) ? wp_verify_nonce($_REQUEST[$query_arg], $action) : false;
if ( !$result && !(-1 == $action && strpos($referer, $adminurl) === 0) ) {
wp_nonce_ays($action);
die();
}
/** /**
* Fires once the admin request has been validated or not. * Fires once the admin request has been validated or not.
@ -1106,6 +1102,12 @@ function check_admin_referer( $action = -1, $query_arg = '_wpnonce' ) {
* 0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago. * 0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
*/ */
do_action( 'check_admin_referer', $action, $result ); do_action( 'check_admin_referer', $action, $result );
if ( ! $result && ! ( -1 == $action && strpos( $referer, $adminurl ) === 0 ) ) {
wp_nonce_ays( $action );
die();
}
return $result; return $result;
} }
endif; endif;