com php-src: Fix compat with libcurl 7.56.1+ and file:// wrapper: ext/curl/interface.c

From: Date: Sun, 03 Dec 2017 11:23:25 +0000
Subject: com php-src: Fix compat with libcurl 7.56.1+ and file:// wrapper: ext/curl/interface.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-100473@lists.php.net to get a copy of this message
Commit: aaf00ae0a99b84f1fb9a053fa08aef2abdab9f2b Author: Anatol Belski <ab@php.net> Sun, 3 Dec 2017 12:23:25 +0100 Parents: cbe60003f12b2b0ef43a96405c0c47a180cd2619 Branches: PHP-7.1 PHP-7.2 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=aaf00ae0a99b84f1fb9a053fa08aef2abdab9f2b Log: Fix compat with libcurl 7.56.1+ and file:// wrapper Since 7.52.x libcurl file:// scheme was implemented in a way described in https://tools.ietf.org/html/draft-ietf-appsawg-file-scheme-16 . The draft is still not accepted and the change contained a BC breach with win32 path handling. It was reported upstream and 7.52.x fixed it, but the BC breaching behavior was reintroduced in 7.56.1. Thus, it is better to handle this on the PHP side. Changed paths: M ext/curl/interface.c Diff: diff --git a/ext/curl/interface.c b/ext/curl/interface.c index c88bbae..f931efb 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -219,6 +219,17 @@ static int php_curl_option_url(php_curl *ch, const char *url, const size_t len) #endif } +#if LIBCURL_VERSION_NUM > 0x073800 && defined(PHP_WIN32) + if (len > sizeof("file://") - 1 && '/' != url[sizeof("file://") - 1] && !strncmp("file://", url, sizeof("file://") - 1) && len < MAXPATHLEN - 2) { + char _tmp[MAXPATHLEN] = {0}; + + memmove(_tmp, "file:///", sizeof("file:///") - 1); + memmove(_tmp + sizeof("file:///") - 1, url + sizeof("file://") - 1, len - sizeof("file://") + 1); + + return php_curl_option_str(ch, CURLOPT_URL, _tmp, len + 1, 0); + } +#endif + return php_curl_option_str(ch, CURLOPT_URL, url, len, 0); } /* }}} */

« previous php.cvs (#100473) next »