这玩意没有漏洞,还时有漏洞被你按下不表?
Info
json_decode ( string $json [, bool $assoc = false [, int $depth = 512 [, int $options = 0 ]]] ) : mixed
(PHP 5 >= 5.2.0, PHP 7, PECL json >= 1.2.0)
json_decode — 对 JSON 格式的字符串进行解码
参数 | 说明 |
---|---|
json | 待解码的 json string 格式的字符串。(RFC 7159) |
assoc | 当该参数为 TRUE 时,将返回 array 而非 object。 |
depth | 指定递归深度。 |
options | JSON解码的掩码选项。 现在有两个支持的选项。 |
JSON_BIGINT_AS_STRING,大整数转为字符串(默认float类型)。 | |
JSON_OBJECT_AS_ARRAY,与将assoc设置为 TRUE 有相同的效果。 |
变化
- 自 PHP 5.2.0 起,JSON 扩展默认内置并编译进了 PHP。
- PHP 5 JSON_checker - Douglas Crockford
- a Pushdown Automaton that very quickly determines.
- PHP 7 中是改进的全新解析器,专门为 PHP 订制,软件许可证为 PHP license。
- re2c 0.16
- Bison 3.0.4
PHP 版本说明
PHP 5 : Call Stack of json_decode (zif_json_decode)
毕竟5已经停止更新了,就简单提及一下
- zif_json_decode ext/json/json.c:831-857
- php_json_decode_ex ext/json/json.c:680-796
- json_utf8_to_utf16 utf8 转 utf16
- new_JSON_parser 初始化
- parse_JSON_ex 解析 ext/json/JSON_parser.c:439-750
- php_json_decode_ex ext/json/json.c:680-796
JSON_parser.c 就是 JSON_checker 的
PHP 7 : Call Stack of json_decode (zif_json_decode)
zif_json_decode
ext/json/json.c:312-362
默认嵌套深度 :depth = PHP_JSON_PARSER_DEFAULT_DEPTH (= 512 [php_json.h])
最大嵌套深度 :depth > INT_MAX (= 2147483647 [php.h])
接受参数并调用php_json_decode_ex
php_json_decode_ex
ext/json/json.c:246-264
- 初始化 PHP 的
json
解析器php_json_parser_init
- 解析 json 字符串
php_json_yyparse
- 如果解析错误,抛出异常及错误信息
- 返回 PHP Object
php_json_yyparse (yyparse)
ext/json/json_parser.tab.c:115
#define yyparse php_json_yyparse
ext/json/json_parser.tab.c:1194-843
点击收藏 | 0
关注 | 1