[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 22/208: url: refactor the check for Windows drive l
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 22/208: url: refactor the check for Windows drive letter in path |
Date: |
Wed, 09 Aug 2017 17:33:39 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to annotated tag gnurl-7.55.0
in repository gnurl.
commit 2a733d641839eda8ff511d780b05bf18894fe603
Author: Jay Satiro <address@hidden>
AuthorDate: Tue Jun 13 21:42:59 2017 -0400
url: refactor the check for Windows drive letter in path
- Move the logic to detect a Windows drive letter prefix
(eg c: in c:foo) into a function-like macro.
Closes https://github.com/curl/curl/pull/1571
---
lib/url.c | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/lib/url.c b/lib/url.c
index 20fdbbbb9..8cd83d3a7 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -4363,11 +4363,16 @@ static CURLcode parseurlandfillconn(struct Curl_easy
*data,
return CURLE_URL_MALFORMAT;
}
- /* Make sure we don't mistake a drive letter for a scheme, for example:
+ /* MSDOS/Windows style drive prefix, eg c: in c:foo */
+#define STARTS_WITH_DRIVE_PREFIX(str) \
+ ((('a' <= str[0] && str[0] <= 'z') || \
+ ('A' <= str[0] && str[0] <= 'Z')) && \
+ (str[1] == ':'))
+
+ /* Don't mistake a drive letter for a scheme if the default protocol is file.
curld --proto-default file c:/foo/bar.txt */
- if((('a' <= data->change.url[0] && data->change.url[0] <= 'z') ||
- ('A' <= data->change.url[0] && data->change.url[0] <= 'Z')) &&
- data->change.url[1] == ':' && data->set.str[STRING_DEFAULT_PROTOCOL] &&
+ if(STARTS_WITH_DRIVE_PREFIX(data->change.url) &&
+ data->set.str[STRING_DEFAULT_PROTOCOL] &&
strcasecompare(data->set.str[STRING_DEFAULT_PROTOCOL], "file")) {
; /* do nothing */
}
@@ -4386,8 +4391,6 @@ static CURLcode parseurlandfillconn(struct Curl_easy
*data,
if((url_has_scheme && strncasecompare(data->change.url, "file:", 5)) ||
(!url_has_scheme && data->set.str[STRING_DEFAULT_PROTOCOL] &&
strcasecompare(data->set.str[STRING_DEFAULT_PROTOCOL], "file"))) {
- bool path_has_drive = FALSE;
-
if(url_has_scheme)
rc = sscanf(data->change.url, "%*15[^\n/:]:%[^\n]", path);
else
@@ -4409,17 +4412,12 @@ static CURLcode parseurlandfillconn(struct Curl_easy
*data,
memmove(path, path + 2, strlen(path + 2)+1);
}
- /* the path may start with a drive letter. for backwards compatibility
- we skip some processing on those paths. */
- path_has_drive = (('a' <= path[0] && path[0] <= 'z') ||
- ('A' <= path[0] && path[0] <= 'Z')) && path[1] == ':';
-
/*
* we deal with file://<host>/<path> differently since it supports no
* hostname other than "localhost" and "127.0.0.1", which is unique among
* the URL protocols specified in RFC 1738
*/
- if(path[0] != '/' && !path_has_drive) {
+ if(path[0] != '/' && !STARTS_WITH_DRIVE_PREFIX(path)) {
/* the URL includes a host name, it must match "localhost" or
"127.0.0.1" to be valid */
char *ptr;
@@ -4453,13 +4451,10 @@ static CURLcode parseurlandfillconn(struct Curl_easy
*data,
/* This cannot be made with strcpy, as the memory chunks overlap! */
memmove(path, ptr, strlen(ptr)+1);
-
- path_has_drive = (('a' <= path[0] && path[0] <= 'z') ||
- ('A' <= path[0] && path[0] <= 'Z')) && path[1] == ':';
}
#if !defined(MSDOS) && !defined(WIN32) && !defined(__CYGWIN__)
- if(path_has_drive) {
+ if(STARTS_WITH_DRIVE_PREFIX(path)) {
failf(data, "File drive letters are only accepted in MSDOS/Windows.");
return CURLE_URL_MALFORMAT;
}
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 24/208: test1148: verify the -# progressbar, (continued)
- [GNUnet-SVN] [gnurl] 24/208: test1148: verify the -# progressbar, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 30/208: curl-compilers.m4: enable vla warning for clang, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 33/208: curl-compilers.m4: enable comma clang warning, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 34/208: Makefile.m32: enable -W for MinGW32 build, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 40/208: http_proxy: fix build with http and proxy, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 51/208: travis: do the distcheck test build out-of-tree as well, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 43/208: PIPELINING_SERVER_BL: cleanup the internal list use, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 37/208: TODO: implement support for CURLOPT_PREQUOTE with SFTP, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 73/208: socks: use proxy_user instead of proxy_name, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 70/208: test1537: fixed memory leak on OOM, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 22/208: url: refactor the check for Windows drive letter in path,
gnunet <=
- [GNUnet-SVN] [gnurl] 54/208: ci: whitelist branches to avoid testing feature branches twice, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 49/208: test1521: test getinfo's OFF_T types too, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 29/208: http-proxy: fix chunked-encoded CONNECT responses, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 74/208: socks: deduplicate the code for auth request, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 69/208: test1521: fix compiler warnings, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 44/208: getinfo: return sizes as curl_off_t, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 31/208: curl-compilers.m4: enable double-promotion warning, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 50/208: http: add --strip-path-slash and CURLOPT_STRIP_PATH_SLASH, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 35/208: curl: prevent binary output spewed to terminal, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 86/208: make: build the docs subdir only from within src, gnunet, 2017/08/09