summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
Diffstat (limited to 'player')
-rw-r--r--player/command.c21
-rw-r--r--player/command.h1
-rw-r--r--player/osd.c4
-rw-r--r--player/playloop.c3
4 files changed, 26 insertions, 3 deletions
diff --git a/player/command.c b/player/command.c
index d9984fc8cb..96b9484781 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2221,6 +2221,27 @@ char *mp_property_expand_string(struct MPContext *mpctx, const char *str)
return m_properties_expand_string(mp_properties, str, mpctx);
}
+// Before expanding properties, parse C-style escapes like "\n"
+char *mp_property_expand_escaped_string(struct MPContext *mpctx, const char *str)
+{
+ void *tmp = talloc_new(NULL);
+ bstr strb = bstr0(str);
+ bstr dst = {0};
+ while (strb.len) {
+ if (!mp_append_escaped_string(tmp, &dst, &strb)) {
+ talloc_free(tmp);
+ return talloc_strdup(NULL, "(broken escape sequences)");
+ }
+ // pass " through literally
+ if (!bstr_eatstart0(&strb, "\""))
+ break;
+ bstr_xappend(tmp, &dst, bstr0("\""));
+ }
+ char *r = mp_property_expand_string(mpctx, dst.start);
+ talloc_free(tmp);
+ return r;
+}
+
void property_print_help(struct mp_log *log)
{
m_properties_print_help_list(log, mp_properties);
diff --git a/player/command.h b/player/command.h
index 61fe1ffad0..a04bfac343 100644
--- a/player/command.h
+++ b/player/command.h
@@ -28,6 +28,7 @@ void command_uninit(struct MPContext *mpctx);
void run_command(struct MPContext *mpctx, struct mp_cmd *cmd);
char *mp_property_expand_string(struct MPContext *mpctx, const char *str);
+char *mp_property_expand_escaped_string(struct MPContext *mpctx, const char *str);
void property_print_help(struct mp_log *log);
int mp_property_do(const char* name, int action, void* val,
struct MPContext *mpctx);
diff --git a/player/osd.c b/player/osd.c
index abfe826a81..d8ba356b33 100644
--- a/player/osd.c
+++ b/player/osd.c
@@ -159,7 +159,7 @@ void print_status(struct MPContext *mpctx)
}
if (opts->status_msg) {
- char *r = mp_property_expand_string(mpctx, opts->status_msg);
+ char *r = mp_property_expand_escaped_string(mpctx, opts->status_msg);
term_osd_set_status(mpctx, r);
talloc_free(r);
return;
@@ -428,7 +428,7 @@ static void sadd_osd_status(char **buffer, struct MPContext *mpctx, bool full)
saddf_osd_function_sym(buffer, sym);
char *custom_msg = mpctx->opts->osd_status_msg;
if (custom_msg && full) {
- char *text = mp_property_expand_string(mpctx, custom_msg);
+ char *text = mp_property_expand_escaped_string(mpctx, custom_msg);
*buffer = talloc_strdup_append(*buffer, text);
talloc_free(text);
} else {
diff --git a/player/playloop.c b/player/playloop.c
index 88adf9e35c..87236a34f0 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -1244,7 +1244,8 @@ void run_playloop(struct MPContext *mpctx)
if (opts->playing_msg && !mpctx->playing_msg_shown && new_frame_shown) {
mpctx->playing_msg_shown = true;
- char *msg = mp_property_expand_string(mpctx, opts->playing_msg);
+ char *msg =
+ mp_property_expand_escaped_string(mpctx, opts->playing_msg);
MP_INFO(mpctx, "%s\n", msg);
talloc_free(msg);
}