properly handle youtube url

previously this case would fail:

http://myserver.com/?dst=www.youtube.com&x=y

we must check ".youtube.com" is before the query start (?).



SVN revision: 77645
This commit is contained in:
Gustavo Sverzut Barbieri 2012-10-09 14:16:45 +00:00
parent c5fcea8bbe
commit 52af5639d7
1 changed files with 17 additions and 6 deletions

View File

@ -1022,15 +1022,26 @@ int
media_src_type_get(const char *src)
{
int type = TYPE_UNKNOWN;
if (_is_fmt(src, extn_img)) type = TYPE_IMG;
else if (_is_fmt(src, extn_scale)) type = TYPE_SCALE;
else if (_is_fmt(src, extn_edj)) type = TYPE_EDJE;
else if (_is_fmt(src, extn_mov)) type = TYPE_MOV;
// handle youtube direct url's
else if ((!strncasecmp(src, "http://", 7)) &&
(strstr(src, ".youtube.com/")) &&
(strchr(src, '=')) &&
(strchr(src, '&'))) type = TYPE_MOV;
else if (!strncasecmp(src, "http://", sizeof("http://") - 1))
{
const char *query;
src += sizeof("http://") - 1;
query = strchr(src, '?');
if (query)
{
if (strchr(query + 1, '=') && strchr(query + 1, '&'))
{
const char *p = strstr(src, ".youtube.com/");
if (p && (p < query))
type = TYPE_MOV;
}
}
}
return type;
}