Skip to content

Commit 97d809a

Browse files
committed
Merge branch 'PHP-5.5' into PHP-5.6
Conflicts: ext/json/json.c
2 parents ffd2fda + 591dbca commit 97d809a

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

ext/json/json.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -427,25 +427,21 @@ static void json_escape_string(smart_str *buf, char *s, int len, int options TSR
427427
if ((type = is_numeric_string(s, len, &p, &d, 0)) != 0) {
428428
if (type == IS_LONG) {
429429
smart_str_append_long(buf, p);
430-
} else if (type == IS_DOUBLE) {
431-
if (!zend_isinf(d) && !zend_isnan(d)) {
432-
char num[NUM_BUF_SIZE];
433-
int l;
434-
435-
php_gcvt(d, EG(precision), '.', 'e', (char *)num);
436-
l = strlen(num);
437-
if (options & PHP_JSON_PRESERVE_ZERO_FRACTION && strchr(num, '.') == NULL && l < NUM_BUF_SIZE - 2) {
438-
num[l++] = '.';
439-
num[l++] = '0';
440-
num[l] = '\0';
441-
}
442-
smart_str_appendl(buf, num, l);
443-
} else {
444-
JSON_G(error_code) = PHP_JSON_ERROR_INF_OR_NAN;
445-
smart_str_appendc(buf, '0');
430+
return;
431+
} else if (type == IS_DOUBLE && !zend_isinf(d) && !zend_isnan(d)) {
432+
char num[NUM_BUF_SIZE];
433+
int l;
434+
435+
php_gcvt(d, EG(precision), '.', 'e', (char *)num);
436+
l = strlen(num);
437+
if (options & PHP_JSON_PRESERVE_ZERO_FRACTION && strchr(num, '.') == NULL && l < NUM_BUF_SIZE - 2) {
438+
num[l++] = '.';
439+
num[l++] = '0';
440+
num[l] = '\0';
446441
}
442+
smart_str_appendl(buf, num, l);
443+
return;
447444
}
448-
return;
449445
}
450446

451447
}

ext/json/tests/bug64695.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug #64695 JSON_NUMERIC_CHECK has issues with strings that are numbers plus the letter e
3+
--SKIPIF--
4+
<?php if (!extension_loaded("json")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
$t = array('test' => '123343e871700');
8+
var_dump(json_encode($t, JSON_NUMERIC_CHECK));
9+
10+
echo "Done\n";
11+
?>
12+
--EXPECT--
13+
string(24) "{"test":"123343e871700"}"
14+
Done

0 commit comments

Comments
 (0)