exlcude the port from hostname
authorMichael Wallner <mike@php.net>
Wed, 30 May 2012 11:07:31 +0000 (11:07 +0000)
committerMichael Wallner <mike@php.net>
Wed, 30 May 2012 11:07:31 +0000 (11:07 +0000)
php_http_url.c

index 0432f329fb970940a4a561d426af784a50f98a8a..efa9116e4b7a8d300b660717a6981e988a0d05d5 100644 (file)
@@ -92,7 +92,9 @@ static php_url *php_http_url_from_env(php_url *url TSRMLS_DC)
        if ((((zhost = php_http_env_get_server_var(ZEND_STRL("HTTP_HOST"), 1 TSRMLS_CC)) ||
                        (zhost = php_http_env_get_server_var(ZEND_STRL("SERVER_NAME"), 1 TSRMLS_CC)) ||
                        (zhost = php_http_env_get_server_var(ZEND_STRL("SERVER_ADDR"), 1 TSRMLS_CC)))) && Z_STRLEN_P(zhost)) {
-               url->host = estrndup(Z_STRVAL_P(zhost), Z_STRLEN_P(zhost));
+               size_t stop_at = strspn(Z_STRVAL_P(zhost), "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-.");
+
+               url->host = estrndup(Z_STRVAL_P(zhost), stop_at);
        } else {
                url->host = localhostname();
        }