From: Laurent Aimar Date: Wed, 21 Feb 2007 21:31:36 +0000 (+0000) Subject: Improved vlc_UrlParse (close #1025) X-Git-Tag: 0.9.0-test0~8489 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=47a67b900609e47dc36610f4c77b7656753b07c1;p=vlc Improved vlc_UrlParse (close #1025) We use vlc_UrlParse for "URL" without protocol... so it was using a part of the URL as a protocol if it found ":/". Ensure to extract only valid protocol at least. --- diff --git a/include/vlc_url.h b/include/vlc_url.h index 99d280fd20..4001596763 100644 --- a/include/vlc_url.h +++ b/include/vlc_url.h @@ -73,7 +73,23 @@ static inline void vlc_UrlParse( vlc_url_t *url, const char *psz_url, } url->psz_buffer = psz_parse = psz_dup = strdup( psz_url ); + /* Search a valid protocol */ p = strstr( psz_parse, ":/" ); + if( p != NULL ) + { + char *p2; + for( p2 = psz_parse; p2 < p; p2++ ) + { +#define I(i,a,b) ( (a) <= (i) && (i) <= (b) ) + if( !I(*p2, 'a', 'z' ) && !I(*p2, 'A', 'Z') && !I(*p2, '0', '9') && *p2 != '+' && *p2 != '-' && *p2 != '.' ) + { + p = NULL; + break; + } +#undef I + } + } + if( p != NULL ) { /* we have a protocol */