mirror of
https://github.com/mpv-player/mpv
synced 2025-03-11 08:37:59 +00:00
player/loadfile: we shouldn't unescape inplace
I got mesmerized by the simplicity of the original commit, but in fact
it was not a correct thing to do.
Fixes: c0366cfa42
This commit is contained in:
parent
de4004c61d
commit
3717a530ca
@ -833,11 +833,13 @@ int mp_add_external_file(struct MPContext *mpctx, char *filename,
|
||||
if (!filename || mp_cancel_test(cancel))
|
||||
return -1;
|
||||
|
||||
void *unescaped_url = NULL;
|
||||
char *disp_filename = filename;
|
||||
if (strncmp(disp_filename, "memory://", 9) == 0)
|
||||
if (strncmp(disp_filename, "memory://", 9) == 0) {
|
||||
disp_filename = "memory://"; // avoid noise
|
||||
else if (mp_is_url(bstr0(disp_filename)))
|
||||
mp_url_unescape_inplace(disp_filename);
|
||||
} else if (mp_is_url(bstr0(disp_filename))) {
|
||||
disp_filename = unescaped_url = mp_url_unescape(NULL, disp_filename);
|
||||
}
|
||||
|
||||
struct demuxer_params params = {
|
||||
.is_top_level = true,
|
||||
@ -915,12 +917,14 @@ int mp_add_external_file(struct MPContext *mpctx, char *filename,
|
||||
|
||||
mp_cancel_set_parent(demuxer->cancel, mpctx->playback_abort);
|
||||
|
||||
talloc_free(unescaped_url);
|
||||
return first_num;
|
||||
|
||||
err_out:
|
||||
demux_cancel_and_free(demuxer);
|
||||
if (!mp_cancel_test(cancel))
|
||||
MP_ERR(mpctx, "Can not open external file %s.\n", disp_filename);
|
||||
talloc_free(unescaped_url);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -156,6 +156,13 @@ void mp_url_unescape_inplace(char *url)
|
||||
}
|
||||
}
|
||||
|
||||
char *mp_url_unescape(void *talloc_ctx, char *url)
|
||||
{
|
||||
char *unescaped = talloc_strdup(talloc_ctx, url);
|
||||
mp_url_unescape_inplace(unescaped);
|
||||
return unescaped;
|
||||
}
|
||||
|
||||
static const char hex_digits[] = "0123456789ABCDEF";
|
||||
|
||||
|
||||
|
@ -260,6 +260,7 @@ struct stream *stream_create(const char *url, int flags,
|
||||
stream_t *open_output_stream(const char *filename, struct mpv_global *global);
|
||||
|
||||
void mp_url_unescape_inplace(char *buf);
|
||||
char *mp_url_unescape(void *talloc_ctx, char *url);
|
||||
char *mp_url_escape(void *talloc_ctx, const char *s, const char *ok);
|
||||
|
||||
// stream_memory.c
|
||||
|
Loading…
Reference in New Issue
Block a user