From 0835d8fa28662c792150bb2c2625a5e43550f778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Mengu=C3=A9?= Date: Mon, 28 Dec 2020 00:42:17 +0100 Subject: [PATCH] Use json_encode with option JSON_UNESCAPED_SLASHES When encoding JSON, use option JSON_UNESCAPED_SLASHES which allows to disable a non-standard unnecessary over-encoding of '/' as '\/' by json_encode. This option of json_encode is available on PHP 5.4+. --- composer.json | 2 +- src/JWT.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 25d1cfa9..bfe3e482 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ ], "license": "BSD-3-Clause", "require": { - "php": ">=5.3.0" + "php": ">=5.4.0" }, "autoload": { "psr-4": { diff --git a/src/JWT.php b/src/JWT.php index c68d4e15..deb2d4ce 100644 --- a/src/JWT.php +++ b/src/JWT.php @@ -322,7 +322,7 @@ public static function jsonDecode($input) */ public static function jsonEncode($input) { - $json = \json_encode($input); + $json = \json_encode($input, JSON_UNESCAPED_SLASHES); if ($errno = \json_last_error()) { static::handleJsonError($errno); } elseif ($json === 'null' && $input !== null) {