Patch json_encode-depth.patch for JSON related Bug #73526
Patch version 2016-11-15 10:43 UTC
Return to Bug #73526 |
Download this patch
Patch Revisions:
Developer: remi
diff --git a/ext/json/json.c b/ext/json/json.c
index 202296c..e8e0ca9 100644
--- a/ext/json/json.c
+++ b/ext/json/json.c
@@ -184,13 +184,18 @@ static PHP_MINFO_FUNCTION(json)
}
/* }}} */
-PHP_JSON_API int php_json_encode(smart_str *buf, zval *val, int options) /* {{{ */
+PHP_JSON_API int php_json_encode(smart_str *buf, zval *val, int options)
+{
+ return php_json_encode_ex(buf, val, options, PHP_JSON_ENCODER_DEFAULT_DEPTH);
+}
+
+PHP_JSON_API int php_json_encode_ex(smart_str *buf, zval *val, int options, int depth) /* {{{ */
{
php_json_encoder encoder;
int return_code;
php_json_encode_init(&encoder);
- encoder.max_depth = JSON_G(encode_max_depth);
+ encoder.max_depth = depth;
encoder.error_code = PHP_JSON_ERROR_NONE;
return_code = php_json_encode_zval(buf, val, options, &encoder);
diff --git a/ext/json/php_json.h b/ext/json/php_json.h
index cedb8ae..a6c347f 100644
--- a/ext/json/php_json.h
+++ b/ext/json/php_json.h
@@ -79,6 +79,7 @@ typedef enum {
/* default depth */
#define PHP_JSON_PARSER_DEFAULT_DEPTH 512
+#define PHP_JSON_ENCODER_DEFAULT_DEPTH 512
ZEND_BEGIN_MODULE_GLOBALS(json)
int encoder_depth;
@@ -93,6 +94,7 @@ PHP_JSON_API ZEND_EXTERN_MODULE_GLOBALS(json)
ZEND_TSRMLS_CACHE_EXTERN()
#endif
+PHP_JSON_API int php_json_encode_ex(smart_str *buf, zval *val, int options, int depth);
PHP_JSON_API int php_json_encode(smart_str *buf, zval *val, int options);
PHP_JSON_API int php_json_decode_ex(zval *return_value, char *str, size_t str_len, zend_long options, zend_long depth);
|