--- wget-1.12.1-devel-orig/src/url.c 2009-09-22 14:04:36 -0400 +++ wget-1.12.1-devel/src/url.c 2009-12-13 00:55:38 -0500 @@ -442,25 +442,34 @@ } #define SCHEME_CHAR(ch) (c_isalnum (ch) || (ch) == '-' || (ch) == '+') +/* Scheme characters should be alphanumeric or + or - */ -/* 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]+: . */ - +/* Return 1 if a possible naming scheme specifier is found, 0 otherwise. */ bool url_has_scheme (const char *url) { const char *p = url; + char *p2; + unsigned scheme_len, i; - /* The first char must be a scheme char. */ - if (!*p || !SCHEME_CHAR (*p)) + assert( p ); + p2 = strstr( p, "://" ); + /* strstr can return p if zero length string */ + + scheme_len = p2 > p ? p2 - p : 0; + + /* if the possible scheme is only one character it is not valid */ + /* also we could have something like C://file.txt */ + if( scheme_len <= 1 ) return false; - ++p; - /* Followed by 0 or more scheme chars. */ - while (*p && SCHEME_CHAR (*p)) - ++p; - /* Terminated by ':'. */ - return *p == ':'; + + for( i = 0; i < scheme_len; ++i, ++p ) + { + if( !SCHEME_CHAR( *p ) ) + return false; + } + + return true; } int