From 4bc7a91be71f833672cc52134e665ce0b08bd61c Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 22:15:05 +0100 Subject: Merge ../phpdbg into PHP-5.6 Conflicts: sapi/phpdbg/config.m4 --- config.m4 | 5 ----- config.w32 | 5 +++++ phpdbg_wait.c | 15 ++++++++------- phpdbg_webdata_transfer.c | 20 +++++++++++++------- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/config.m4 b/config.m4 index b8aa8526c5..9603be105c 100644 --- a/config.m4 +++ b/config.m4 @@ -25,11 +25,6 @@ if test "$BUILD_PHPDBG" == "" && test "$PHP_PHPDBG" != "no"; then if ! test -d $abs_srcdir/ext/phpdbg_webhelper; then ln -s ../sapi/phpdbg $abs_srcdir/ext/phpdbg_webhelper fi - if test "$PHP_JSON" != "no"; then - PHP_NEW_EXTENSION(phpdbg_webhelper, phpdbg_rinit_hook.c phpdbg_webdata_transfer.c, $ext_shared) - else - AC_MSG_ERROR(Webhelper extension of phpdbg needs json enabled) - fi fi PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE" diff --git a/config.w32 b/config.w32 index 6f0bd8f811..651c7e6d16 100644 --- a/config.w32 +++ b/config.w32 @@ -1,5 +1,6 @@ ARG_ENABLE('phpdbg', 'Build phpdbg', 'no'); ARG_ENABLE('phpdbgs', 'Build phpdbg shared', 'no'); +ARG_ENABLE('phpdbgwebhelper', 'Build phpdbg webhelper', 'yes'); PHPDBG_SOURCES='phpdbg.c phpdbg_prompt.c phpdbg_cmd.c phpdbg_info.c phpdbg_help.c phpdbg_break.c ' + 'phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c ' + @@ -14,6 +15,10 @@ if (PHP_PHPDBG == "yes") { ADD_FLAG("LIBS_PHPDBG", "ws2_32.lib user32.lib"); ADD_FLAG("CFLAGS_PHPDBG", "/D YY_NO_UNISTD_H"); ADD_FLAG("LDFLAGS_PHPDBG", "/stack:8388608"); + + if (PHP_PHPDBGWEBHELPER == "yes") { + EXTENSION('phpdbg-webhelper', 'phpdbg_rinit_hook.c phpdbg_webdata_compress.c'); + } } if (PHP_PHPDBGS == "yes") { diff --git a/phpdbg_wait.c b/phpdbg_wait.c index ea506a2d93..bdce77180b 100644 --- a/phpdbg_wait.c +++ b/phpdbg_wait.c @@ -18,7 +18,7 @@ #include "phpdbg_wait.h" #include "phpdbg_prompt.h" -#include "ext/json/JSON_parser.h" +#include "ext/standard/php_var.h" #include "ext/standard/basic_functions.h" ZEND_EXTERN_MODULE_GLOBALS(phpdbg); @@ -127,16 +127,18 @@ static int phpdbg_array_intersect(phpdbg_intersect_ptr *info, zval ***ptr) { } void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) { -#ifdef HAVE_JSON zval *free_zv = NULL; - zval zv, **zvpp; + zval zv, *zvp = &zv, **zvpp; HashTable *ht; - php_json_decode(&zv, msg, len, 1, 1000 /* enough */ TSRMLS_CC); + php_unserialize_data_t var_hash; - if (JSON_G(error_code) != PHP_JSON_ERROR_NONE) { - phpdbg_error("wait", "type=\"invaliddata\" import=\"fail\"", "Malformed JSON was sent to this socket, arborting"); + PHP_VAR_UNSERIALIZE_INIT(var_hash); + if (!php_var_unserialize(&zvp, (const unsigned char **) &msg, (unsigned char *) msg + len, &var_hash TSRMLS_CC)) { + PHP_VAR_UNSERIALIZE_DESTROY(var_hash); + phpdbg_error("wait", "type=\"invaliddata\" import=\"fail\"", "Malformed serialized was sent to this socket, arborting"); return; } + PHP_VAR_UNSERIALIZE_DESTROY(var_hash); ht = Z_ARRVAL(zv); @@ -358,7 +360,6 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) { /* Reapply raw input */ /* ??? */ -#endif } PHPDBG_COMMAND(wait) /* {{{ */ diff --git a/phpdbg_webdata_transfer.c b/phpdbg_webdata_transfer.c index e7438ea01a..1cbc4107b5 100644 --- a/phpdbg_webdata_transfer.c +++ b/phpdbg_webdata_transfer.c @@ -17,11 +17,9 @@ */ #include "phpdbg_webdata_transfer.h" -#include "ext/json/php_json.h" +#include "ext/standard/php_var.h" PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len TSRMLS_DC) { -#ifdef HAVE_JSON - smart_str buf = {0}; zval array; HashTable *ht; /* I really need to change that to an array of zvals... */ @@ -177,9 +175,17 @@ PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len TSRMLS_DC) { } /* encode data */ - php_json_encode(&buf, &array, 0 TSRMLS_CC); - *msg = buf.c; - *len = buf.len; + { + php_serialize_data_t var_hash; + smart_str buf = {0}; + zval *arrayptr = &array; + + PHP_VAR_SERIALIZE_INIT(var_hash); + php_var_serialize(&buf, &arrayptr, &var_hash TSRMLS_CC); + PHP_VAR_SERIALIZE_DESTROY(var_hash); + *msg = buf.c; + *len = buf.len; + } + zval_dtor(&array); -#endif } -- cgit v1.2.1 From 45e2dc692b9b0ad13c32444622d85c0353aaee42 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 22:44:29 +0100 Subject: Merge phpdbg into PHP-5.6 --- config.m4 | 1 + phpdbg_wait.c | 2 ++ phpdbg_webdata_transfer.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/config.m4 b/config.m4 index 9603be105c..87d38ea8c5 100644 --- a/config.m4 +++ b/config.m4 @@ -25,6 +25,7 @@ if test "$BUILD_PHPDBG" == "" && test "$PHP_PHPDBG" != "no"; then if ! test -d $abs_srcdir/ext/phpdbg_webhelper; then ln -s ../sapi/phpdbg $abs_srcdir/ext/phpdbg_webhelper fi + PHP_NEW_EXTENSION(phpdbg_webhelper, phpdbg_rinit_hook.c phpdbg_webdata_transfer.c, $ext_shared) fi PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE" diff --git a/phpdbg_wait.c b/phpdbg_wait.c index bdce77180b..a8c7dd49cb 100644 --- a/phpdbg_wait.c +++ b/phpdbg_wait.c @@ -174,6 +174,7 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) { free_zv = *zvpp; } +#if PHP_VERSION_ID >= 50600 if (zend_hash_find(ht, "input", sizeof("input"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_STRING) { if (SG(request_info).request_body) { php_stream_close(SG(request_info).request_body); @@ -182,6 +183,7 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) { php_stream_truncate_set_size(SG(request_info).request_body, 0); php_stream_write(SG(request_info).request_body, Z_STRVAL_PP(zvpp), Z_STRLEN_PP(zvpp)); } +#endif if (zend_hash_find(ht, "cwd", sizeof("cwd"), (void **) &zvpp) == SUCCESS && Z_TYPE_PP(zvpp) == IS_STRING) { if (VCWD_CHDIR(Z_STRVAL_PP(zvpp)) == SUCCESS) { diff --git a/phpdbg_webdata_transfer.c b/phpdbg_webdata_transfer.c index 1cbc4107b5..7c169ee113 100644 --- a/phpdbg_webdata_transfer.c +++ b/phpdbg_webdata_transfer.c @@ -49,6 +49,7 @@ PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len TSRMLS_DC) { zend_hash_add(ht, "GLOBALS", sizeof("GLOBALS"), &zvp1, sizeof(zval *), NULL); } +#if PHP_VERSION_ID >= 50600 /* save php://input */ { php_stream *stream; @@ -64,6 +65,7 @@ PHPDBG_API void phpdbg_webdata_compress(char **msg, int *len TSRMLS_DC) { Z_SET_REFCOUNT(zv2, 2); zend_hash_add(ht, "input", sizeof("input"), &zvp2, sizeof(zval *), NULL); } +#endif /* change sapi name */ { -- cgit v1.2.1 From beb767dbe09dbb9cd65d5d1562b1f14e9b420911 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 28 Oct 2014 23:06:50 +0100 Subject: Merge phpdbg into PHP-5.6 --- phpdbg_wait.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpdbg_wait.c b/phpdbg_wait.c index a8c7dd49cb..3f5ee24faa 100644 --- a/phpdbg_wait.c +++ b/phpdbg_wait.c @@ -366,7 +366,6 @@ void phpdbg_webdata_decompress(char *msg, int len TSRMLS_DC) { PHPDBG_COMMAND(wait) /* {{{ */ { -#ifdef HAVE_JSON struct sockaddr_un local, remote; int rlen, sr, sl; unlink(PHPDBG_G(socket_path)); @@ -418,5 +417,4 @@ PHPDBG_COMMAND(wait) /* {{{ */ phpdbg_notice("wait", "import=\"success\"", "Successfully imported request data, stopped before executing"); return SUCCESS; -#endif } /* }}} */ -- cgit v1.2.1 From 89e613cf01b1a57da3ee4431b43296bd92342397 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 29 Oct 2014 07:26:41 +0100 Subject: cleanup uneeded json --- phpdbg_wait.c | 1 - 1 file changed, 1 deletion(-) diff --git a/phpdbg_wait.c b/phpdbg_wait.c index 3f5ee24faa..95024b8d77 100644 --- a/phpdbg_wait.c +++ b/phpdbg_wait.c @@ -22,7 +22,6 @@ #include "ext/standard/basic_functions.h" ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -ZEND_EXTERN_MODULE_GLOBALS(json); static void phpdbg_rebuild_http_globals_array(int type, const char *name TSRMLS_DC) { zval **zvpp; -- cgit v1.2.1