- 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 a7e0f3c..27b602d 100644 (file)
@@ -1,3 +1,4 @@
+#! /usr/bin/php
 <?php
 
 function hl($m)
diff --git a/http.c b/http.c
index 899083f..41456dc 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 7a17391..e026052 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 e6ed74a..6f5b034 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 dff4cae..01a2e41 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 31137dd..162d495 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));