Bug #80678 [Opn->Nab]: json_decode fails on numbers with explizit "+" sign
| From: | nikic@php.net | Date: | Thu, 28 Jan 2021 10:44:26 +0000 |
| Subject: | Bug #80678 [Opn->Nab]: json_decode fails on numbers with explizit "+" sign | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-231807@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80678&edit=1
ID: 80678
Updated by: nikic@php.net
Reported by: rainer-phpbugs at 7val dot com
Summary: json_decode fails on numbers with explizit "+" sign
-Status: Open
+Status: Not a bug
Type: Bug
Package: JSON related
Operating System: all
PHP Version: 8.0.1
Block user comment: N
Private report: N
New Comment:
A + sign is only allowed as part of a floating-point exponent, such as 1.0e+1. Just +1 in isolation
is malformed JSON.
Previous Comments:
------------------------------------------------------------------------
[2021-01-28 10:42:21] phpbugs at canavan dot de
The following patch has been added/updated:
Patch Name: json_decode_positive_sign.patch
Revision: 1611830541
URL: https://bugs.php.net/patch-display.php?bug=80678&patch=json_decode_positive_sign.patch&revision=1611830541
------------------------------------------------------------------------
[2021-01-28 10:40:39] rainer-phpbugs at 7val dot com
Description:
------------
The JSON standard allows positive numbers to be represented with an explicit "+" sign,
e.g. +123 (see the "sign" production on https://www.json.org/json-en.html). json_decode() fails
and returns NULL for any JSON string that contains such a number.
Also affects 7.3 and 7.4 branches.
Test script:
---------------
<?php
$x=json_decode('+123.4');
var_export($x);
print("\n");
$x=json_decode('123.4');
var_export($x);
print("\n");
Expected result:
----------------
123.4
123.4
Actual result:
--------------
NULL
123.4
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80678&edit=1