← All changes
|
jetpack_vendor/automattic/jetpack-sync/src/class-json-deflate-array-codec.php
+10
-3
12.5.2
→
16.3-a.7
View file →
| @@ -7,8 +7,12 @@ | ||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | namespace Automattic\Jetpack\Sync; |
| 10 | 10 | |
| 11 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 12 | + exit( 0 ); | |
| 13 | +} | |
| 14 | + | |
| 11 | 15 | /** |
| 12 | 16 | * An implementation of Automattic\Jetpack\Sync\Codec_Interface that uses gzip's DEFLATE |
| 13 | 17 | * algorithm to compress objects serialized using json_encode |
| 14 | 18 | */ |
| @@ -40,9 +44,12 @@ | ||
| 40 | 44 | * @param string $input Item to decode. |
| 41 | 45 | * @return array|mixed|object |
| 42 | 46 | */ |
| 43 | 47 | public function decode( $input ) { |
| 44 | - return $this->json_unserialize( gzinflate( base64_decode( $input ) ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode | |
| 48 | + $decoded = base64_decode( $input ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode | |
| 49 | + $inflated = @gzinflate( $decoded ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged | |
| 50 | + | |
| 51 | + return is_string( $inflated ) ? $this->json_unserialize( $inflated ) : null; | |
| 45 | 52 | } |
| 46 | 53 | |
| 47 | 54 | /** |
| 48 | 55 | * Serialize JSON |
| @@ -48,14 +55,14 @@ | ||
| 48 | 55 | * Serialize JSON |
| 49 | 56 | * |
| 50 | 57 | * @see https://gist.github.com/muhqu/820694 |
| 51 | 58 | * |
| 52 | - * @param string $any Value to serialize and wrap. | |
| 59 | + * @param mixed $any Value to serialize and wrap. | |
| 53 | 60 | * |
| 54 | 61 | * @return false|string |
| 55 | 62 | */ |
| 56 | 63 | protected function json_serialize( $any ) { |
| 57 | - return wp_json_encode( Functions::json_wrap( $any ) ); | |
| 64 | + return wp_json_encode( Functions::json_wrap( $any ), JSON_UNESCAPED_SLASHES ); | |
| 58 | 65 | } |
| 59 | 66 | |
| 60 | 67 | /** |
| 61 | 68 | * Unserialize JSON |