From: Michael Wallner Date: Mon, 7 May 2012 10:46:12 +0000 (+0000) Subject: don't sanitize URL path by default, and add http\Url::SANITIZE_PATH flag for that X-Git-Tag: RELEASE_2_1_0_RC3~10^2^2~132 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=commitdiff_plain;h=dc34435880de3900616a80a2466105790e7a118a don't sanitize URL path by default, and add http\Url::SANITIZE_PATH flag for that --- diff --git a/php_http_url.c b/php_http_url.c index c8fe62e..0432f32 100644 --- a/php_http_url.c +++ b/php_http_url.c @@ -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; } diff --git a/php_http_url.h b/php_http_url.h index cc663ac..022ba31 100644 --- a/php_http_url.h +++ b/php_http_url.h @@ -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);