From d558accaa69af1a0dcce0997f6343b4bc1e3f91d Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 21 Jan 2015 12:10:45 +0100 Subject: stream_lavf: escape disallowed characters in http URLs In my opinion, libavformat should be doing this. But a patch handling a very safe case rejected, so I suppose we have to do it manually. (This patch was only escaping spaces, which can never work because they break the basic syntax of the HTTP protocol.) This commit attempts to do 2 things: - Try to guess whether libavformat will use the URL for http. This is not always trivial, because some protocols will recursively pass part of the user URL to http in some way. - Try to fix invalid URLs. We fix only the simplest case: only characters that are never valid are escaped. This excludes invalid escape codes, which happen with freestanding '%' characters. Fixes #1495. --- stream/stream.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'stream/stream.c') diff --git a/stream/stream.c b/stream/stream.c index de362a6ee1..1e1c5eee4e 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -157,7 +157,7 @@ void mp_url_unescape_inplace(char *buf) // ok[0] != '~': additional characters that are not escaped // ok[0] == '~': do not escape anything but these characters // (can't override the unreserved characters, which are -// never escaped, and '%', which is always escaped) +// never escaped) char *mp_url_escape(void *talloc_ctx, const char *s, const char *ok) { int len = strlen(s); @@ -167,7 +167,7 @@ char *mp_url_escape(void *talloc_ctx, const char *s, const char *ok) unsigned char c = s[i]; if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || strchr("-._~", c) || - (ok && ((ok[0] != '~') == !!strchr(ok, c)) && c != '%')) + (ok && ((ok[0] != '~') == !!strchr(ok, c)))) { buf[o++] = c; } else { -- cgit v1.2.3