summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Raynor <chris@firebase.com>2014-06-25 13:50:56 -0700
committerChris Raynor <chris@firebase.com>2014-06-25 13:50:56 -0700
commitd6c2f29dbcaefec6a2f277f1185ccdb0fe9edbc1 (patch)
treeace14e7529e3abdc12b0b3c5df0f159c3aa34169
parent718e9c732255da4fbd7314319043ebdf14f7cb12 (diff)
downloadphp-jwt-d6c2f29dbcaefec6a2f277f1185ccdb0fe9edbc1.zip
php-jwt-d6c2f29dbcaefec6a2f277f1185ccdb0fe9edbc1.tar.gz
php-jwt-d6c2f29dbcaefec6a2f277f1185ccdb0fe9edbc1.tar.bz2
This fixes #9 - Improve check for offending json-c implementation with missing implementation of JSON_BIGINT_AS_STRING on 64 bit systems
-rw-r--r--Authentication/JWT.php4
1 files changed, 2 insertions, 2 deletions
diff --git a/Authentication/JWT.php b/Authentication/JWT.php
index 8eefaad..65be7a1 100644
--- a/Authentication/JWT.php
+++ b/Authentication/JWT.php
@@ -130,7 +130,7 @@ class JWT
*/
public static function jsonDecode($input)
{
- if (version_compare(PHP_VERSION, '5.4.0', '>=') && defined('JSON_BIGINT_AS_STRING')) {
+ if (version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) {
/* In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you to specify that large ints (like Steam
* Transaction IDs) should be treated as strings, rather than the PHP default behaviour of converting them to floats.
*/
@@ -140,7 +140,7 @@ class JWT
* string and quote them (thus converting them to strings) before decoding, hence the preg_replace() call.
*/
$max_int_length = strlen((string) PHP_INT_MAX) - 1;
- $json_without_bigints = preg_replace('/:\s*(\d{'.$max_int_length.',})/', ': "$1"', $input);
+ $json_without_bigints = preg_replace('/:\s*(-?\d{'.$max_int_length.',})/', ': "$1"', $input);
$obj = json_decode($json_without_bigints);
}