From b0f8e03f17c3dca88fa28265e88f7ec4c0d01d4d Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 4 Sep 2013 14:31:08 +0200 Subject: 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. --- mpvcore/command.c | 9 +++++++-- 1 file 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, -- cgit v1.2.3