Mercurial > libavformat.hg
changeset 6274:1c656ac8c9c9 libavformat
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.
author | mru |
---|---|
date | Sun, 18 Jul 2010 18:38:23 +0000 |
parents | 2f7d2aa56191 |
children | 287072e5227b |
files | avio.c |
diffstat | 1 files changed, 10 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/avio.c Sun Jul 18 08:15:45 2010 +0000 +++ b/avio.c Sun Jul 18 18:38:23 2010 +0000 @@ -167,29 +167,21 @@ return ret; } +#define URL_SCHEME_CHARS \ + "abcdefghijklmnopqrstuvwxyz" \ + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ + "0123456789+-." + int url_alloc(URLContext **puc, const char *filename, int flags) { URLProtocol *up; - const char *p; - char proto_str[128], *q; + char proto_str[128]; + size_t proto_len = strspn(filename, URL_SCHEME_CHARS); - p = 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: + if (filename[proto_len] != ':' || is_dos_path(filename)) strcpy(proto_str, "file"); - } else { - *q = '\0'; - } + else + av_strlcpy(proto_str, filename, FFMIN(proto_len+1, sizeof(proto_str))); up = first_protocol; while (up != NULL) {