- fix endless loop in http_build_url() with urls like "/.foo"
authorMichael Wallner <mike@php.net>
Fri, 3 Feb 2006 09:06:51 +0000 (09:06 +0000)
committerMichael Wallner <mike@php.net>
Fri, 3 Feb 2006 09:06:51 +0000 (09:06 +0000)
- reset HTTP_GLOBALS->read_post_data for each request
- allow HttpQueryString objects as param its methods

funcsummary.php
http.c
http_querystring_object.c
http_request_object.c
http_url_api.c
tests/HttpQueryString_001.phpt

index a7e0f3c3fc5200f5b9ea4477443d9307bfb86c8a..27b602d95fa0e471ccacc664ec263f6b1f38d570 100644 (file)
@@ -1,3 +1,4 @@
+#! /usr/bin/php
 <?php
 
 function hl($m)
diff --git a/http.c b/http.c
index 899083fcb9b7ee3a6a0631e023ad336f730638fa..41456dc3f8f7ac7d5462f7963c4aab0160f0761d 100644 (file)
--- a/http.c
+++ b/http.c
@@ -171,6 +171,7 @@ static inline void _http_globals_init(zend_http_globals *G TSRMLS_DC)
 #ifndef HTTP_HAVE_SAPI_RTIME
        G->request_time = time(NULL);
 #endif
+       G->read_post_data = 0;
 }
 
 #define http_globals_free(g) _http_globals_free((g) TSRMLS_CC)
index 7a17391e946bbedfcaf5fddc7edfa972f0d12ca1..e026052e3c3394cb5c87c5c0f2f133b85276c6ef 100644 (file)
@@ -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;
index e6ed74ae0aaafd0dd2e876e746296e8322bdc08e..6f5b0345f0ca4e20299abc6d972d6713daefdc48 100644 (file)
@@ -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;
index dff4caec0a78d6e73483ea9669d3c0f3b458183c..01a2e41c464e03a22f8757ec695b5586e58656ca 100644 (file)
@@ -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;
                        }
                }
        }
index 31137dd48252ba07361bd4b32c39dede64a8259f..162d49593af2c254fce577a22721c87f48e5d790 100644 (file)
@@ -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));