Skip to content

Commit 1af449f

Browse files
committed
Merge branch 'master' into zend_signals
* master: Improved support for zend-signals. Use empty keys instead of _empty_ in json decoding update NEWS Fix bug #71936 (Segmentation fault destroying HTTP_RAW_POST_DATA)
2 parents 72376dc + 8953308 commit 1af449f

File tree

8 files changed

+18
-18
lines changed

8 files changed

+18
-18
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ PHP NEWS
1212
finishes). (Nikita)
1313
. Fixed bug #69489 (tempnam() should raise notice if falling back to temp dir).
1414
(Laruence, Anatol)
15+
. Fixed UTF-8 and long path support on Windows. (Anatol)
1516

1617
- GD:
1718
. Fixed bug #43475 (Thick styled lines have scrambled patterns). (cmb)
1819
. Fixed bug #53640 (XBM images require width to be multiple of 8). (cmb)
1920
. Fixed bug #64641 (imagefilledpolygon doesn't draw horizontal line). (cmb)
2021

22+
- JSON
23+
. Implemented FR #46600 ("_empty_" key in objects). (Jakub Zelenka)
24+
2125
- Mbstring:
2226
. Fixed bug #72405 (mb_ereg_replace - mbc_to_code (oniguruma) -
2327
oob read access). (Laruence)

UPGRADING

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ PHP 7.1 UPGRADE NOTES
4646
the notice level only.
4747

4848
- JSON:
49+
. An empty key is decoded as an empty property name instead of using _empty_
50+
property name when decoding object to stdClass.
4951
. When calling json_encode with JSON_UNESCAPED_UNICODE option, U+2028 and
5052
U+2029 are escaped.
5153

ext/json/json_encoder.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static void php_json_encode_array(smart_str *buf, zval *val, int options) /* {{{
169169
php_json_encode(buf, data, options);
170170
} else if (r == PHP_JSON_OUTPUT_OBJECT) {
171171
if (key) {
172-
if (ZSTR_VAL(key)[0] == '\0' && Z_TYPE_P(val) == IS_OBJECT) {
172+
if (ZSTR_VAL(key)[0] == '\0' && ZSTR_LEN(key) > 0 && Z_TYPE_P(val) == IS_OBJECT) {
173173
/* Skip protected and private members. */
174174
if (tmp_ht && ZEND_HASH_APPLY_PROTECTION(tmp_ht)) {
175175
ZEND_HASH_DEC_APPLY_COUNT(tmp_ht);

ext/json/json_parser.tab.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,10 +1881,7 @@ static int php_json_parser_object_update(php_json_parser *parser, zval *object,
18811881
zend_symtable_update(Z_ARRVAL_P(object), key, zvalue);
18821882
} else {
18831883
zval zkey;
1884-
if (ZSTR_LEN(key) == 0) {
1885-
zend_string_release(key);
1886-
key = zend_string_init("_empty_", sizeof("_empty_") - 1, 0);
1887-
} else if (ZSTR_VAL(key)[0] == '\0') {
1884+
if (ZSTR_LEN(key) > 0 && ZSTR_VAL(key)[0] == '\0') {
18881885
parser->scanner.errcode = PHP_JSON_ERROR_INVALID_PROPERTY_NAME;
18891886
zend_string_release(key);
18901887
zval_dtor(zvalue);

ext/json/json_parser.y

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,7 @@ static int php_json_parser_object_update(php_json_parser *parser, zval *object,
273273
zend_symtable_update(Z_ARRVAL_P(object), key, zvalue);
274274
} else {
275275
zval zkey;
276-
if (ZSTR_LEN(key) == 0) {
277-
zend_string_release(key);
278-
key = zend_string_init("_empty_", sizeof("_empty_") - 1, 0);
279-
} else if (ZSTR_VAL(key)[0] == '\0') {
276+
if (ZSTR_LEN(key) > 0 && ZSTR_VAL(key)[0] == '\0') {
280277
parser->scanner.errcode = PHP_JSON_ERROR_INVALID_PROPERTY_NAME;
281278
zend_string_release(key);
282279
zval_dtor(zvalue);

ext/json/tests/001.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ object(stdClass)#%d (1) {
5353
}
5454
}
5555
object(stdClass)#%d (1) {
56-
["_empty_"]=>
56+
[""]=>
5757
object(stdClass)#%d (1) {
5858
["foo"]=>
5959
string(0) ""
6060
}
6161
}
6262
object(stdClass)#%d (1) {
63-
["_empty_"]=>
63+
[""]=>
6464
object(stdClass)#%d (1) {
65-
["_empty_"]=>
65+
[""]=>
6666
string(0) ""
6767
}
6868
}

ext/json/tests/pass001.1_64bit.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ array(14) {
204204
float(1.23456789E-13)
205205
["E"]=>
206206
float(1.23456789E+34)
207-
["_empty_"]=>
207+
[""]=>
208208
float(INF)
209209
["E no ."]=>
210210
float(4000000000000)
@@ -527,7 +527,7 @@ array(14) {
527527
string(7) "rosebud"
528528
}
529529
ENCODE: FROM OBJECT
530-
["JSON Test Pattern pass1",{"object with 1 member":["array with 1 element"]},{},[],-42,true,false,null,{"integer":1234567890,"real":-9876.54321,"e":1.23456789e-13,"E":1.23456789e+34,"_empty_":0,"E no .":4000000000000,"zero":0,"one":1,"space":" ","quote":"\"","backslash":"\\","controls":"\b\f\n\r\t","slash":"\/ & \/","alpha":"abcdefghijklmnopqrstuvwyz","ALPHA":"ABCDEFGHIJKLMNOPQRSTUVWYZ","digit":"0123456789","special":"`1~!@#$%^&*()_+-={':[,]}|;.<\/>?","hex":"\u0123\u4567\u89ab\ucdef\uabcd\uef4a","unicode":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8","\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8","empty_string":"","true":true,"false":false,"null":null,"array":[],"object":{},"123":{"456":{"abc":{"789":"def","012":[1,2,"5",500],"ghi":[1,2,"five",50,"sixty"]}}},"address":"50 St. James Street","url":"http:\/\/www.JSON.org\/","comment":"\/\/ \/* <!-- --","# -- --> *\/":" "," s p a c e d ":[1,2,3,4,5,6,7],"compact":[1,2,3,4,5,6,7],"jsontext":"{\"object with 1 member\":[\"array with 1 element\"]}","quotes":"&#34; \" %22 0x22 034 &#x22;","\/\\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',.\/<>?":"A key can be any string"},0.5,98.6,99.44,1066,"rosebud"]
530+
["JSON Test Pattern pass1",{"object with 1 member":["array with 1 element"]},{},[],-42,true,false,null,{"integer":1234567890,"real":-9876.54321,"e":1.23456789e-13,"E":1.23456789e+34,"":0,"E no .":4000000000000,"zero":0,"one":1,"space":" ","quote":"\"","backslash":"\\","controls":"\b\f\n\r\t","slash":"\/ & \/","alpha":"abcdefghijklmnopqrstuvwyz","ALPHA":"ABCDEFGHIJKLMNOPQRSTUVWYZ","digit":"0123456789","special":"`1~!@#$%^&*()_+-={':[,]}|;.<\/>?","hex":"\u0123\u4567\u89ab\ucdef\uabcd\uef4a","unicode":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8","\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8","empty_string":"","true":true,"false":false,"null":null,"array":[],"object":{},"123":{"456":{"abc":{"789":"def","012":[1,2,"5",500],"ghi":[1,2,"five",50,"sixty"]}}},"address":"50 St. James Street","url":"http:\/\/www.JSON.org\/","comment":"\/\/ \/* <!-- --","# -- --> *\/":" "," s p a c e d ":[1,2,3,4,5,6,7],"compact":[1,2,3,4,5,6,7],"jsontext":"{\"object with 1 member\":[\"array with 1 element\"]}","quotes":"&#34; \" %22 0x22 034 &#x22;","\/\\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',.\/<>?":"A key can be any string"},0.5,98.6,99.44,1066,"rosebud"]
531531
ENCODE: FROM ARRAY
532532
["JSON Test Pattern pass1",{"object with 1 member":["array with 1 element"]},[],[],-42,true,false,null,{"integer":1234567890,"real":-9876.54321,"e":1.23456789e-13,"E":1.23456789e+34,"":0,"E no .":4000000000000,"zero":0,"one":1,"space":" ","quote":"\"","backslash":"\\","controls":"\b\f\n\r\t","slash":"\/ & \/","alpha":"abcdefghijklmnopqrstuvwyz","ALPHA":"ABCDEFGHIJKLMNOPQRSTUVWYZ","digit":"0123456789","special":"`1~!@#$%^&*()_+-={':[,]}|;.<\/>?","hex":"\u0123\u4567\u89ab\ucdef\uabcd\uef4a","unicode":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8","\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8","empty_string":"","true":true,"false":false,"null":null,"array":[],"object":[],"123":{"456":{"abc":{"789":"def","012":[1,2,"5",500],"ghi":[1,2,"five",50,"sixty"]}}},"address":"50 St. James Street","url":"http:\/\/www.JSON.org\/","comment":"\/\/ \/* <!-- --","# -- --> *\/":" "," s p a c e d ":[1,2,3,4,5,6,7],"compact":[1,2,3,4,5,6,7],"jsontext":"{\"object with 1 member\":[\"array with 1 element\"]}","quotes":"&#34; \" %22 0x22 034 &#x22;","\/\\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',.\/<>?":"A key can be any string"},0.5,98.6,99.44,1066,"rosebud"]
533533
DECODE AGAIN: AS OBJECT
@@ -566,7 +566,7 @@ array(14) {
566566
float(1.23456789E-13)
567567
["E"]=>
568568
float(1.23456789E+34)
569-
["_empty_"]=>
569+
[""]=>
570570
int(0)
571571
["E no ."]=>
572572
int(4000000000000)

ext/json/tests/pass001.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ array(14) {
188188
float(1.23456789E-13)
189189
["E"]=>
190190
float(1.23456789E+34)
191-
["_empty_"]=>
191+
[""]=>
192192
float(INF)
193193
["zero"]=>
194194
int(0)
@@ -425,7 +425,7 @@ array(14) {
425425
string(7) "rosebud"
426426
}
427427
ENCODE: FROM OBJECT
428-
["JSON Test Pattern pass1",{"object with 1 member":["array with 1 element"]},{},[],-42,true,false,null,{"integer":1234567890,"real":-9876.54321,"e":1.23456789e-13,"E":1.23456789e+34,"_empty_":0,"zero":0,"one":1,"space":" ","quote":"\"","backslash":"\\","controls":"\b\f\n\r\t","slash":"\/ & \/","alpha":"abcdefghijklmnopqrstuvwyz","ALPHA":"ABCDEFGHIJKLMNOPQRSTUVWYZ","digit":"0123456789","special":"`1~!@#$%^&*()_+-={':[,]}|;.<\/>?","hex":"\u0123\u4567\u89ab\ucdef\uabcd\uef4a","true":true,"false":false,"null":null,"array":[],"object":{},"address":"50 St. James Street","url":"http:\/\/www.JSON.org\/","comment":"\/\/ \/* <!-- --","# -- --> *\/":" "," s p a c e d ":[1,2,3,4,5,6,7],"compact":[1,2,3,4,5,6,7],"jsontext":"{\"object with 1 member\":[\"array with 1 element\"]}","quotes":"&#34; \" %22 0x22 034 &#x22;","\/\\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',.\/<>?":"A key can be any string"},0.5,98.6,99.44,1066,"rosebud"]
428+
["JSON Test Pattern pass1",{"object with 1 member":["array with 1 element"]},{},[],-42,true,false,null,{"integer":1234567890,"real":-9876.54321,"e":1.23456789e-13,"E":1.23456789e+34,"":0,"zero":0,"one":1,"space":" ","quote":"\"","backslash":"\\","controls":"\b\f\n\r\t","slash":"\/ & \/","alpha":"abcdefghijklmnopqrstuvwyz","ALPHA":"ABCDEFGHIJKLMNOPQRSTUVWYZ","digit":"0123456789","special":"`1~!@#$%^&*()_+-={':[,]}|;.<\/>?","hex":"\u0123\u4567\u89ab\ucdef\uabcd\uef4a","true":true,"false":false,"null":null,"array":[],"object":{},"address":"50 St. James Street","url":"http:\/\/www.JSON.org\/","comment":"\/\/ \/* <!-- --","# -- --> *\/":" "," s p a c e d ":[1,2,3,4,5,6,7],"compact":[1,2,3,4,5,6,7],"jsontext":"{\"object with 1 member\":[\"array with 1 element\"]}","quotes":"&#34; \" %22 0x22 034 &#x22;","\/\\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',.\/<>?":"A key can be any string"},0.5,98.6,99.44,1066,"rosebud"]
429429
ENCODE: FROM ARRAY
430430
["JSON Test Pattern pass1",{"object with 1 member":["array with 1 element"]},[],[],-42,true,false,null,{"integer":1234567890,"real":-9876.54321,"e":1.23456789e-13,"E":1.23456789e+34,"":0,"zero":0,"one":1,"space":" ","quote":"\"","backslash":"\\","controls":"\b\f\n\r\t","slash":"\/ & \/","alpha":"abcdefghijklmnopqrstuvwyz","ALPHA":"ABCDEFGHIJKLMNOPQRSTUVWYZ","digit":"0123456789","special":"`1~!@#$%^&*()_+-={':[,]}|;.<\/>?","hex":"\u0123\u4567\u89ab\ucdef\uabcd\uef4a","true":true,"false":false,"null":null,"array":[],"object":[],"address":"50 St. James Street","url":"http:\/\/www.JSON.org\/","comment":"\/\/ \/* <!-- --","# -- --> *\/":" "," s p a c e d ":[1,2,3,4,5,6,7],"compact":[1,2,3,4,5,6,7],"jsontext":"{\"object with 1 member\":[\"array with 1 element\"]}","quotes":"&#34; \" %22 0x22 034 &#x22;","\/\\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',.\/<>?":"A key can be any string"},0.5,98.6,99.44,1066,"rosebud"]
431431
DECODE AGAIN: AS OBJECT
@@ -464,7 +464,7 @@ array(14) {
464464
float(1.23456789E-13)
465465
["E"]=>
466466
float(1.23456789E+34)
467-
["_empty_"]=>
467+
[""]=>
468468
int(0)
469469
["zero"]=>
470470
int(0)

0 commit comments

Comments
 (0)