mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-5.5' into PHP-5.6
Conflicts: ext/json/json.c
This commit is contained in:
commit
97d809a8a5
2 changed files with 26 additions and 16 deletions
|
@ -427,25 +427,21 @@ 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 num[NUM_BUF_SIZE];
|
||||
int l;
|
||||
return;
|
||||
} else if (type == IS_DOUBLE && !zend_isinf(d) && !zend_isnan(d)) {
|
||||
char num[NUM_BUF_SIZE];
|
||||
int l;
|
||||
|
||||
php_gcvt(d, EG(precision), '.', 'e', (char *)num);
|
||||
l = strlen(num);
|
||||
if (options & PHP_JSON_PRESERVE_ZERO_FRACTION && strchr(num, '.') == NULL && l < NUM_BUF_SIZE - 2) {
|
||||
num[l++] = '.';
|
||||
num[l++] = '0';
|
||||
num[l] = '\0';
|
||||
}
|
||||
smart_str_appendl(buf, num, l);
|
||||
} else {
|
||||
JSON_G(error_code) = PHP_JSON_ERROR_INF_OR_NAN;
|
||||
smart_str_appendc(buf, '0');
|
||||
php_gcvt(d, EG(precision), '.', 'e', (char *)num);
|
||||
l = strlen(num);
|
||||
if (options & PHP_JSON_PRESERVE_ZERO_FRACTION && strchr(num, '.') == NULL && l < NUM_BUF_SIZE - 2) {
|
||||
num[l++] = '.';
|
||||
num[l++] = '0';
|
||||
num[l] = '\0';
|
||||
}
|
||||
smart_str_appendl(buf, num, l);
|
||||
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…
Add table
Add a link
Reference in a new issue