diff options
author | Jörg Frings-Fürst <debian@jff-webhsoting.net> | 2018-09-08 10:21:01 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhsoting.net> | 2018-09-08 10:21:01 +0200 |
commit | 273a72f7b6ffa258ef3735ef44d3adf254b04c3f (patch) | |
tree | 642b60314bb654c66dd926dd10f112cae4f257f4 /src/UriFile.c | |
parent | e94f3be22cd927eb2b5d9554eae2032a971c7e7e (diff) | |
parent | 21ce7e27a89c3f9c2fb4bc8bd59877dc2d8cd6b9 (diff) |
Update upstream source from tag 'upstream/0.8.6'
Update to upstream version '0.8.6'
with Debian dir dab399747c753aac5012df1b62df1aee932286fc
Diffstat (limited to 'src/UriFile.c')
-rw-r--r-- | src/UriFile.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/UriFile.c b/src/UriFile.c index 332f6a9..303ee49 100644 --- a/src/UriFile.c +++ b/src/UriFile.c @@ -104,7 +104,7 @@ static URI_INLINE int URI_FUNC(FilenameToUriString)(const URI_CHAR * filename, if ((input[0] == _UT('\0')) || (fromUnix && input[0] == _UT('/')) || (!fromUnix && input[0] == _UT('\\'))) { - /* Copy text after last seperator */ + /* Copy text after last separator */ if (lastSep + 1 < input) { if (!fromUnix && absolute && (firstSegment == URI_TRUE)) { /* Quick hack to not convert "C:" to "C%3A" */ @@ -148,13 +148,17 @@ static URI_INLINE int URI_FUNC(UriStringToFilename)(const URI_CHAR * uriString, } { - const UriBool file_two_slashes = - URI_STRNCMP(uriString, _UT("file://"), URI_STRLEN(_UT("file://"))) == 0; - const UriBool file_three_slashes = file_two_slashes + const UriBool file_unknown_slashes = + URI_STRNCMP(uriString, _UT("file:"), URI_STRLEN(_UT("file:"))) == 0; + const UriBool file_one_or_more_slashes = file_unknown_slashes + && (URI_STRNCMP(uriString, _UT("file:/"), URI_STRLEN(_UT("file:/"))) == 0); + const UriBool file_two_or_more_slashes = file_one_or_more_slashes + && (URI_STRNCMP(uriString, _UT("file://"), URI_STRLEN(_UT("file://"))) == 0); + const UriBool file_three_or_more_slashes = file_two_or_more_slashes && (URI_STRNCMP(uriString, _UT("file:///"), URI_STRLEN(_UT("file:///"))) == 0); - const size_t charsToSkip = file_two_slashes - ? file_three_slashes + const size_t charsToSkip = file_two_or_more_slashes + ? file_three_or_more_slashes ? toUnix /* file:///bin/bash */ ? URI_STRLEN(_UT("file://")) @@ -162,13 +166,21 @@ static URI_INLINE int URI_FUNC(UriStringToFilename)(const URI_CHAR * uriString, : URI_STRLEN(_UT("file:///")) /* file://Server01/Letter.txt */ : URI_STRLEN(_UT("file://")) - : 0; + : ((file_one_or_more_slashes && toUnix) + /* file:/bin/bash */ + /* https://tools.ietf.org/html/rfc8089#appendix-B */ + ? URI_STRLEN(_UT("file:")) + : ((! toUnix && file_unknown_slashes && ! file_one_or_more_slashes) + /* file:c:/path/to/file */ + /* https://tools.ietf.org/html/rfc8089#appendix-E.2 */ + ? URI_STRLEN(_UT("file:")) + : 0)); const size_t charsToCopy = URI_STRLEN(uriString + charsToSkip) + 1; const UriBool is_windows_network_with_authority = (toUnix == URI_FALSE) - && file_two_slashes - && ! file_three_slashes; + && file_two_or_more_slashes + && ! file_three_or_more_slashes; URI_CHAR * const unescape_target = is_windows_network_with_authority ? (filename + 2) |