Skip to content
Snippets Groups Projects
Commit 2bab5d3e authored by Måns Rullgård's avatar Måns Rullgård
Browse files

Allow all valid (and only valid) characters in URL scheme for url_open()

The URL specification allows letters, numbers, plus, hyphen, and period
in the scheme part.  The isalpha() test would allow additional characters
depending on locale settings while rejecting numbers and punctuation.

Originally committed as revision 24306 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent d62ccec8
No related branches found
No related tags found
No related merge requests found
...@@ -167,29 +167,21 @@ int url_open_protocol (URLContext **puc, struct URLProtocol *up, ...@@ -167,29 +167,21 @@ int url_open_protocol (URLContext **puc, struct URLProtocol *up,
return ret; return ret;
} }
#define URL_SCHEME_CHARS \
"abcdefghijklmnopqrstuvwxyz" \
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
"0123456789+-."
int url_alloc(URLContext **puc, const char *filename, int flags) int url_alloc(URLContext **puc, const char *filename, int flags)
{ {
URLProtocol *up; URLProtocol *up;
const char *p; char proto_str[128];
char proto_str[128], *q; size_t proto_len = strspn(filename, URL_SCHEME_CHARS);
p = filename; if (filename[proto_len] != ':' || is_dos_path(filename))
q = proto_str;
while (*p != '\0' && *p != ':') {
/* protocols can only contain alphabetic chars */
if (!isalpha(*p))
goto file_proto;
if ((q - proto_str) < sizeof(proto_str) - 1)
*q++ = *p;
p++;
}
/* if the protocol has length 1, we consider it is a dos drive */
if (*p == '\0' || is_dos_path(filename)) {
file_proto:
strcpy(proto_str, "file"); strcpy(proto_str, "file");
} else { else
*q = '\0'; av_strlcpy(proto_str, filename, FFMIN(proto_len+1, sizeof(proto_str)));
}
up = first_protocol; up = first_protocol;
while (up != NULL) { while (up != NULL) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment