Skip to content

Commit aaf00ae

Browse files
committed
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.
1 parent cbe6000 commit aaf00ae

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ext/curl/interface.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,17 @@ static int php_curl_option_url(php_curl *ch, const char *url, const size_t len)
219219
#endif
220220
}
221221

222+
#if LIBCURL_VERSION_NUM > 0x073800 && defined(PHP_WIN32)
223+
if (len > sizeof("file://") - 1 && '/' != url[sizeof("file://") - 1] && !strncmp("file://", url, sizeof("file://") - 1) && len < MAXPATHLEN - 2) {
224+
char _tmp[MAXPATHLEN] = {0};
225+
226+
memmove(_tmp, "file:///", sizeof("file:///") - 1);
227+
memmove(_tmp + sizeof("file:///") - 1, url + sizeof("file://") - 1, len - sizeof("file://") + 1);
228+
229+
return php_curl_option_str(ch, CURLOPT_URL, _tmp, len + 1, 0);
230+
}
231+
#endif
232+
222233
return php_curl_option_str(ch, CURLOPT_URL, url, len, 0);
223234
}
224235
/* }}} */

0 commit comments

Comments
 (0)