don't sanitize URL path by default, and add http\Url::SANITIZE_PATH flag for that
authorMichael Wallner <mike@php.net>
Mon, 7 May 2012 10:46:12 +0000 (10:46 +0000)
committerMichael Wallner <mike@php.net>
Mon, 7 May 2012 10:46:12 +0000 (10:46 +0000)
php_http_url.c
php_http_url.h

index c8fe62e85e37819f5db7dcb2504ec08efa669a14..0432f329fb970940a4a561d426af784a50f98a8a 100644 (file)
@@ -222,7 +222,8 @@ PHP_HTTP_API void php_http_url(int flags, const php_url *old_url, const php_url
                STR_SET(url->path, path);
        }
        /* replace directory references if path is not a single slash */
-       if (url->path[0] && (url->path[0] != '/' || url->path[1])) {
+       if ((flags & PHP_HTTP_URL_SANITIZE_PATH)
+       &&      url->path[0] && (url->path[0] != '/' || url->path[1])) {
                char *ptr, *end = url->path + strlen(url->path) + 1;
                        
                for (ptr = strchr(url->path, '/'); ptr; ptr = strchr(ptr, '/')) {
@@ -642,6 +643,7 @@ PHP_MINIT_FUNCTION(http_url)
        zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("STRIP_FRAGMENT"), PHP_HTTP_URL_STRIP_FRAGMENT TSRMLS_CC);
        zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("STRIP_ALL"), PHP_HTTP_URL_STRIP_ALL TSRMLS_CC);
        zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("FROM_ENV"), PHP_HTTP_URL_FROM_ENV TSRMLS_CC);
+       zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("SANITIZE_PATH"), PHP_HTTP_URL_SANITIZE_PATH TSRMLS_CC);
 
        return SUCCESS;
 }
index cc663acaa2edc7ae68487948807a851f648d84b2..022ba31b0113dde448acf9476f8b585805a8bce0 100644 (file)
@@ -33,6 +33,7 @@
        PHP_HTTP_URL_STRIP_FRAGMENT \
 )
 #define PHP_HTTP_URL_FROM_ENV          0x1000
+#define PHP_HTTP_URL_SANITIZE_PATH     0x2000
 
 PHP_HTTP_API void php_http_url(int flags, const php_url *old_url, const php_url *new_url, php_url **url_ptr, char **url_str, size_t *url_len TSRMLS_DC);