com php-src: Fix bug #64695 (JSON_NUMERIC_CHECK has i ssues with strings that are numbers plus the le tter e): NEWS ext/json/json.c ext/json/tests/bug
64695.phpt
| From: | Jakub Zelenka | Date: | Sun, 22 Feb 2015 20:22:47 +0000 |
| Subject: | com php-src: Fix bug #64695 (JSON_NUMERIC_CHECK has i ssues with strings that are numbers plus the le tter e): NEWS ext/json/json.c ext/json/tests/bug 64695.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-85057@lists.php.net to get a copy of this message | ||
Commit: 591dbcabe57a32550fb73223521fa1323773628f
Author: Jakub Zelenka <bukka@php.net> Sun, 22 Feb 2015 20:22:47 +0000
Parents: 7ea5b3f71cb7291f88659ecf810916c34b1b6f4a
Branches: PHP-5.5
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=591dbcabe57a32550fb73223521fa1323773628f
Log:
Fix bug #64695 (JSON_NUMERIC_CHECK has issues with strings that are numbers plus the letter e)
Bugs:
https://bugs.php.net/64695
Changed paths:
M NEWS
M ext/json/json.c
A ext/json/tests/bug64695.phpt
Diff:
diff --git a/NEWS b/NEWS
index a4f98ff..fa8ce9d 100644
--- a/NEWS
+++ b/NEWS
@@ -630,6 +630,8 @@ PHP NEWS
- JSON:
. Fixed bug #66021 (Blank line inside empty array/object when
JSON_PRETTY_PRINT is set). (Kevin Israel)
+ . Fixed bug #64695 (JSON_NUMERIC_CHECK has issues with strings that are
+ numbers plus the letter e). (Jakub Zelenka)
- LDAP:
. Fixed issue with null bytes in LDAP bindings. (Matthew Daley)
diff --git a/ext/json/json.c b/ext/json/json.c
index 5b71eb0..16af796 100644
--- a/ext/json/json.c
+++ b/ext/json/json.c
@@ -418,18 +418,14 @@ static void json_escape_string(smart_str *buf, char *s, int len, int options
TSR
if ((type = is_numeric_string(s, len, &p, &d, 0)) != 0) {
if (type == IS_LONG) {
smart_str_append_long(buf, p);
- } else if (type == IS_DOUBLE) {
- if (!zend_isinf(d) && !zend_isnan(d)) {
- char *tmp;
- int l = spprintf(&tmp, 0, "%.*k", (int) EG(precision), d);
- smart_str_appendl(buf, tmp, l);
- efree(tmp);
- } else {
- JSON_G(error_code) = PHP_JSON_ERROR_INF_OR_NAN;
- smart_str_appendc(buf, '0');
- }
+ return;
+ } else if (type == IS_DOUBLE && !zend_isinf(d) && !zend_isnan(d)) {
+ char *tmp;
+ int l = spprintf(&tmp, 0, "%.*k", (int) EG(precision), d);
+ smart_str_appendl(buf, tmp, l);
+ efree(tmp);
+ return;
}
- return;
}
}
diff --git a/ext/json/tests/bug64695.phpt b/ext/json/tests/bug64695.phpt
new file mode 100644
index 0000000..899259f
--- /dev/null
+++ b/ext/json/tests/bug64695.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #64695 JSON_NUMERIC_CHECK has issues with strings that are numbers plus the letter e
+--SKIPIF--
+<?php if (!extension_loaded("json")) print "skip"; ?>
+--FILE--
+<?php
+$t = array('test' => '123343e871700');
+var_dump(json_encode($t, JSON_NUMERIC_CHECK));
+
+echo "Done\n";
+?>
+--EXPECT--
+string(24) "{"test":"123343e871700"}"
+Done