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.
This commit is contained in:
wm4
2013-08-02 17:03:30 +02:00
parent f8589c9889
commit 44d6ac06ae
4 changed files with 41 additions and 0 deletions

View File

@@ -1050,6 +1050,10 @@ static int ifo_stream_open (stream_t *stream, int mode)
stream->priv = priv;
*priv = stream_priv_dflts;
// "file://" prefix -> decode URL-style escapes
if (strlen(stream->url) > strlen(stream->path))
mp_url_unescape_inplace(stream->path);
int len = strlen(stream->path);
if (len < 4 || strcasecmp (stream->path + len - 4, ".ifo"))
return STREAM_UNSUPPORTED;