From 44d6ac06aed7c13cbace543920e706023551c3c2 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 2 Aug 2013 17:03:30 +0200 Subject: stream: parse URL escapes for file:// So for example "file:///file%20name.mkv" will open "file name.mkv". I'm not sure whether we want/need this. The old code didn't do it. Also, it's not really clear whether this is handled correctly. It seems the corresponding freedesktop.org "standard" allows a (useless) hostname part, which we should skip in theory. The number of slashes is not really clear either. We can open relative filenames (by removing one of the slashes from the example above), which is perhaps an unneeded feature. How does this even work with Windows paths? This issues can probably be corrected later. The URL unescape code is based on code from m_option.c removed with a recent commit. --- stream/stream_file.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'stream/stream_file.c') diff --git a/stream/stream_file.c b/stream/stream_file.c index dc85314f71..1e9f372ba4 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -125,6 +125,10 @@ static int open_f(stream_t *stream, int mode) return STREAM_UNSUPPORTED; } + // "file://" prefix -> decode URL-style escapes + if (strlen(stream->url) > strlen(stream->path)) + mp_url_unescape_inplace(stream->path); + #if HAVE_DOS_PATHS // extract '/' from '/x:/path' if( filename[ 0 ] == '/' && filename[ 1 ] && filename[ 2 ] == ':' ) -- cgit v1.2.3