Ray Satiro <[email protected]> wrote:
> I checked the source and it appears that the 'unsupported scheme' error is
> caused because the path on windows can be misinterpreted as a URL. This
> traces back to retrieve_from_file() in src/retr.c.
>
> 1.12.1-devel retrieve_from_file() is different from 1.11.4 in the way it
> handles checking for a URL as the input file. Changes could be made to retr.c
> retrieve_from_file() or maybe url.c url_has_scheme(), which doesn't really
> validate any type of scheme.
>
> Attached is a patch that eliminates the check in retrieve_from_file() for
> url_has_scheme() and instead checks url_parse() to see determine if the input
> file is a URL. This is probably sufficient since url_parse() checks
> url_scheme().
I'd prefer patching url_has_scheme() to test for schemes more strictly;
the implementation would add a check for a double slash at the end of
the scheme and colon (which are part of the URL).
Attached a patch for review.
diff -r 38a0105c05ea src/url.c
--- a/src/url.c Sat Oct 24 16:06:44 2009 -0700
+++ b/src/url.c Fri Dec 11 20:34:10 2009 +0100
@@ -445,7 +445,7 @@
/* Return 1 if the URL begins with any "scheme", 0 otherwise. As
currently implemented, it returns true if URL begins with
- [-+a-zA-Z0-9]+: . */
+ [-+a-zA-Z0-9]+:// . */
bool
url_has_scheme (const char *url)
@@ -460,7 +460,11 @@
while (*p && SCHEME_CHAR (*p))
++p;
/* Terminated by ':'. */
- return *p == ':';
+ if (*p != ':')
+ return false;
+ ++p;
+ /* Ending double slash. */
+ return strstr (p, "//") ? true : false;
}
int