mirror of
https://github.com/php/php-src.git
synced 2024-11-28 04:14:26 +08:00
Fix bug #64695 (JSON_NUMERIC_CHECK has issues with strings that are numbers plus the letter e)
This commit is contained in:
parent
7ea5b3f71c
commit
591dbcabe5
2
NEWS
2
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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
14
ext/json/tests/bug64695.phpt
Normal file
14
ext/json/tests/bug64695.phpt
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user