summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-09-04 14:31:08 +0200
committerwm4 <wm4@nowhere>2013-09-04 16:15:09 +0200
commitb0f8e03f17c3dca88fa28265e88f7ec4c0d01d4d (patch)
tree725a00efa28515931585e8243c4a07e032710e2e /mpvcore
parentefc5ac17bf0a563cc4200252e8d4718731dc9fde (diff)
downloadmpv-b0f8e03f17c3dca88fa28265e88f7ec4c0d01d4d.tar.bz2
mpv-b0f8e03f17c3dca88fa28265e88f7ec4c0d01d4d.tar.xz
command: unescape URLs for ${filename} and ${media-title}
Undo URL percent encoding if the filename appears to be an URL. This will fix display of the actual filename in some cases. We don't put any effort into checking whether the URL is really percent encoded, because we don't really know how the protocol handler is going to interpret the URL. For stream_lavf, we probably can't know. Still, from the perspective of this commit, it seems to make sense to assume they are percent encoded.
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/command.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/mpvcore/command.c b/mpvcore/command.c
index 9fdee17387..1a50504b8b 100644
--- a/mpvcore/command.c
+++ b/mpvcore/command.c
@@ -155,8 +155,13 @@ static int mp_property_filename(m_option_t *prop, int action, void *arg,
{
if (!mpctx->filename)
return M_PROPERTY_UNAVAILABLE;
- char *f = (char *)mp_basename(mpctx->filename);
- return m_property_strdup_ro(prop, action, arg, (*f) ? f : mpctx->filename);
+ char *filename = talloc_strdup(NULL, mpctx->filename);
+ if (mp_is_url(bstr0(filename)))
+ mp_url_unescape_inplace(filename);
+ char *f = (char *)mp_basename(filename);
+ int r = m_property_strdup_ro(prop, action, arg, f[0] ? f : filename);
+ talloc_free(filename);
+ return r;
}
static int mp_property_media_title(m_option_t *prop, int action, void *arg,