php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #80678
Patch json_decode_positive_sign.patch revision 2021-01-28 10:42 UTC by phpbugs at canavan dot de

Patch json_decode_positive_sign.patch for JSON related Bug #80678

Patch version 2021-01-28 10:42 UTC

Return to Bug #80678 | Download this patch
Patch Revisions:

Developer: phpbugs@canavan.de

diff --git a/ext/json/json_scanner.re b/ext/json/json_scanner.re
index c8e3e0ebf5..6f48cf522e 100644
--- a/ext/json/json_scanner.re
+++ b/ext/json/json_scanner.re
@@ -113,7 +113,7 @@ std:
 	DIGIT   = [0-9] ;
 	DIGITNZ = [1-9] ;
 	UINT    = "0" | ( DIGITNZ DIGIT* ) ;
-	INT     = "-"? UINT ;
+	INT     = ( "+" | "-" ) ? UINT ;
 	HEX     = DIGIT | [a-fA-F] ;
 	HEXNZ   = DIGITNZ | [a-fA-F] ;
 	HEX7    = [0-7] ;
diff --git a/ext/json/tests/bug80678.phpt b/ext/json/tests/bug80678.phpt
new file mode 100644
index 0000000000..283540e921
--- /dev/null
+++ b/ext/json/tests/bug80678.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #80678 (json_decode() fails on numbers with explicit "+" sign)
+--FILE--
+<?php
+
+var_dump(json_decode('+123.456'));
+
+echo "Done\n";
+?>
+--EXPECT--
+123.456
+Done
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC