From: Michael Wallner Date: Fri, 3 Feb 2006 09:06:51 +0000 (+0000) Subject: - fix endless loop in http_build_url() with urls like "/.foo" X-Git-Tag: RELEASE_0_22_0~3 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=0ecd173659b63e77e47271e5bd521599cd9e500f;p=m6w6%2Fext-http - fix endless loop in http_build_url() with urls like "/.foo" - reset HTTP_GLOBALS->read_post_data for each request - allow HttpQueryString objects as param its methods --- diff --git a/funcsummary.php b/funcsummary.php index a7e0f3c..27b602d 100644 --- a/funcsummary.php +++ b/funcsummary.php @@ -1,3 +1,4 @@ +#! /usr/bin/php request_time = time(NULL); #endif + G->read_post_data = 0; } #define http_globals_free(g) _http_globals_free((g) TSRMLS_CC) diff --git a/http_querystring_object.c b/http_querystring_object.c index 7a17391..e026052 100644 --- a/http_querystring_object.c +++ b/http_querystring_object.c @@ -222,7 +222,9 @@ static inline int _http_querystring_modify_array(zval *qarray, zval *array TSRML #define http_querystring_modify(q, p) _http_querystring_modify((q), (p) TSRMLS_CC) static inline int _http_querystring_modify(zval *qarray, zval *params TSRMLS_DC) { - if (Z_TYPE_P(params) == IS_ARRAY) { + if ((Z_TYPE_P(params) == IS_OBJECT) && instanceof_function(Z_OBJCE_P(params), http_querystring_object_ce TSRMLS_CC)) { + return http_querystring_modify_array(qarray, GET_PROP_EX(params, queryArray)); + } else if (Z_TYPE_P(params) == IS_ARRAY) { return http_querystring_modify_array(qarray, params); } else { int rv; diff --git a/http_request_object.c b/http_request_object.c index e6ed74a..6f5b034 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -1013,7 +1013,6 @@ PHP_METHOD(HttpRequest, setContentType) { char *ctype; int ct_len; - getObject(http_request_object, obj); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &ctype, &ct_len)) { RETURN_FALSE; @@ -1055,7 +1054,6 @@ PHP_METHOD(HttpRequest, getContentType) PHP_METHOD(HttpRequest, setQueryData) { zval *qdata = NULL; - getObject(http_request_object, obj); if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z!", &qdata)) { RETURN_FALSE; diff --git a/http_url_api.c b/http_url_api.c index dff4cae..01a2e41 100644 --- a/http_url_api.c +++ b/http_url_api.c @@ -208,6 +208,11 @@ PHP_HTTP_API void _http_build_url(int flags, const php_url *old_url, const php_u memmove(&ptr[1], pos, end - pos); } break; + + default: + /* something else */ + ++ptr; + break; } } } diff --git a/tests/HttpQueryString_001.phpt b/tests/HttpQueryString_001.phpt index 31137dd..162d495 100644 --- a/tests/HttpQueryString_001.phpt +++ b/tests/HttpQueryString_001.phpt @@ -25,7 +25,7 @@ var_dump(HttpQueryString::getInstance()->get('r')); var_dump(HttpQueryString::getInstance()->get('r', HttpQueryString::TYPE_ARRAY)); var_dump(HttpQueryString::getInstance()->get('r', HttpQueryString::TYPE_OBJECT)); -HttpQueryString::getInstance()->set('z[0]=2'); +HttpQueryString::getInstance()->set(new HttpQueryString(false, 'z[0]=2')); HttpQueryString::getInstance()->set(array('a'=>'b', 'c'=> "3.4")); HttpQueryString::getInstance()->set(array('a' => NULL));