diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2016-11-30 16:22:57 -0500 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2016-11-30 16:22:57 -0500 |
commit | fbf8cf39f7ec35489332158cb2f73ea535279e5b (patch) | |
tree | b8025a3b964e60077492449c0e35bf675bcd6939 /plugins/jetpack/class.jetpack-signature.php | |
parent | Update plugin openid to 3.4.2 (diff) | |
download | blogs-gentoo-fbf8cf39f7ec35489332158cb2f73ea535279e5b.tar.gz blogs-gentoo-fbf8cf39f7ec35489332158cb2f73ea535279e5b.tar.bz2 blogs-gentoo-fbf8cf39f7ec35489332158cb2f73ea535279e5b.zip |
Update plugin jetpack to 4.4.1
Diffstat (limited to 'plugins/jetpack/class.jetpack-signature.php')
-rw-r--r-- | plugins/jetpack/class.jetpack-signature.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/plugins/jetpack/class.jetpack-signature.php b/plugins/jetpack/class.jetpack-signature.php index d8940aaa..66921f61 100644 --- a/plugins/jetpack/class.jetpack-signature.php +++ b/plugins/jetpack/class.jetpack-signature.php @@ -63,6 +63,15 @@ class Jetpack_Signature { $body = $override['body']; } else if ( 'POST' == strtoupper( $_SERVER['REQUEST_METHOD'] ) ) { $body = isset( $GLOBALS['HTTP_RAW_POST_DATA'] ) ? $GLOBALS['HTTP_RAW_POST_DATA'] : null; + + // Convert the $_POST to the body, if the body was empty. This is how arrays are hashed + // and encoded on the Jetpack side. + if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { + if ( empty( $body ) && is_array( $_POST ) && count( $_POST ) > 0 ) { + $body = $_POST; + } + } + } else { $body = null; } @@ -96,6 +105,16 @@ class Jetpack_Signature { return new Jetpack_Error( 'token_mismatch', 'Incorrect token' ); } + // If we got an array at this point, let's encode it, so we can see what it looks like as a string. + if ( is_array( $body ) ) { + if ( count( $body ) > 0 ) { + $body = json_encode( $body ); + + } else { + $body = ''; + } + } + $required_parameters = array( 'token', 'timestamp', 'nonce', 'method', 'url' ); if ( !is_null( $body ) ) { $required_parameters[] = 'body_hash'; @@ -114,7 +133,7 @@ class Jetpack_Signature { } } - if ( is_null( $body ) ) { + if ( empty( $body ) ) { if ( $body_hash ) { return new Jetpack_Error( 'invalid_body_hash', 'The body hash does not match.' ); } |