PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
← All changes | extensions/blocks/premium-content/_inc/subscription-service/class-jwt.php +7 -20 13.4.5 → 16.3 View file →
@@ -12,8 +12,12 @@
12 12 use DomainException;
13 13 use InvalidArgumentException;
14 14 use UnexpectedValueException;
15 15
16 +if ( ! defined( 'ABSPATH' ) ) {
17 + exit( 0 );
18 +}
19 +
16 20 /**
17 21 * JSON Web Token implementation, based on this spec:
18 22 * https://tools.ietf.org/html/rfc7519
19 23 *
@@ -298,24 +302,9 @@
298 302 *
299 303 * @throws DomainException Provided string was invalid JSON.
300 304 */
301 305 public static function json_decode( $input ) {
302 - if ( version_compare( PHP_VERSION, '5.4.0', '>=' ) && ! ( defined( 'JSON_C_VERSION' ) && PHP_INT_SIZE > 4 ) ) {
303 - /** In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you
304 - * to specify that large ints (like Steam Transaction IDs) should be treated as
305 - * strings, rather than the PHP default behaviour of converting them to floats.
306 - */
307 - $obj = json_decode( $input, false, 512, JSON_BIGINT_AS_STRING );
308 - } else {
309 - /** Not all servers will support that, however, so for older versions we must
310 - * manually detect large ints in the JSON string and quote them (thus converting
311 - *them to strings) before decoding, hence the preg_replace() call.
312 - */
313 - $max_int_length = strlen( (string) PHP_INT_MAX ) - 1;
314 - $json_without_bigints = preg_replace( '/:\s*(-?\d{' . $max_int_length . ',})/', ': "$1"', $input );
315 - $obj = json_decode( $json_without_bigints );
316 - }
317 -
306 + $obj = json_decode( $input, false, 512, JSON_BIGINT_AS_STRING );
318 307 $errno = json_last_error();
319 308
320 309 if ( $errno ) {
321 310 static::handle_json_error( $errno );
@@ -334,9 +323,9 @@
334 323 *
335 324 * @throws DomainException Provided object could not be encoded to valid JSON.
336 325 */
337 326 public static function json_encode( $input ) {
338 - $json = wp_json_encode( $input );
327 + $json = wp_json_encode( $input, JSON_UNESCAPED_SLASHES );
339 328 $errno = json_last_error();
340 329
341 330 if ( $errno ) {
342 331 static::handle_json_error( $errno );
@@ -391,11 +380,9 @@
391 380 JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON',
392 381 JSON_ERROR_UTF8 => 'Malformed UTF-8 characters',
393 382 );
394 383 throw new DomainException(
395 - isset( $messages[ $errno ] )
396 - ? $messages[ $errno ]
397 - : 'Unknown JSON error: ' . $errno
384 + $messages[ $errno ] ?? 'Unknown JSON error: ' . $errno
398 385 );
399 386 }
400 387
401 388 /**