summaryrefslogtreecommitdiffstats
path: root/options
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-06-10 23:06:07 +0200
committerwm4 <wm4@nowhere>2015-06-10 23:06:07 +0200
commita3d561f950e74fe7e54fa9c4c6ade05181ecc1ed (patch)
tree7b07ae55badf14b5f3ef7fefbc445641db966456 /options
parent7de2411c4778d177fbab58afdd7a04e8012c7d2b (diff)
downloadmpv-a3d561f950e74fe7e54fa9c4c6ade05181ecc1ed.tar.bz2
mpv-a3d561f950e74fe7e54fa9c4c6ade05181ecc1ed.tar.xz
options: make keyvalue list parsing less strict
Affects for example --script-opts. A bunch of characters are now allowed in them without causing trouble to the user.
Diffstat (limited to 'options')
-rw-r--r--options/m_option.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/options/m_option.c b/options/m_option.c
index bd8e3357b9..8acdc8390d 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -1515,7 +1515,7 @@ const m_option_type_t m_option_type_string_append_list = {
.set = str_list_set,
};
-static int read_subparam(struct mp_log *log, bstr optname,
+static int read_subparam(struct mp_log *log, bstr optname, char *termset,
bstr *str, bstr *out_subparam);
static int parse_keyvalue_list(struct mp_log *log, const m_option_t *opt,
@@ -1527,7 +1527,7 @@ static int parse_keyvalue_list(struct mp_log *log, const m_option_t *opt,
while (param.len) {
bstr key, val;
- r = read_subparam(log, name, &param, &key);
+ r = read_subparam(log, name, "=", &param, &key);
if (r < 0)
break;
if (!bstr_eatstart0(&param, "=")) {
@@ -1535,7 +1535,7 @@ static int parse_keyvalue_list(struct mp_log *log, const m_option_t *opt,
r = M_OPT_INVALID;
break;
}
- r = read_subparam(log, name, &param, &val);
+ r = read_subparam(log, name, ",:", &param, &val);
if (r < 0)
break;
if (dst) {
@@ -1717,9 +1717,10 @@ const m_option_type_t m_option_type_print_fn = {
#define VAL(x) (*(char ***)(x))
// Read s sub-option name, or a positional sub-opt value.
+// termset is a string containing the set of chars that terminate an option.
// Return 0 on succes, M_OPT_ error code otherwise.
// optname is for error reporting.
-static int read_subparam(struct mp_log *log, bstr optname,
+static int read_subparam(struct mp_log *log, bstr optname, char *termset,
bstr *str, bstr *out_subparam)
{
bstr p = *str;
@@ -1764,7 +1765,7 @@ static int read_subparam(struct mp_log *log, bstr optname,
} else {
// Skip until the next character that could possibly be a meta
// character in option parsing.
- int optlen = bstrcspn(p, ":=,\\%\"'[]");
+ int optlen = bstrcspn(p, termset);
subparam = bstr_splice(p, 0, optlen);
p = bstr_cut(p, optlen);
}
@@ -1784,11 +1785,11 @@ static int split_subconf(struct mp_log *log, bstr optname, bstr *str,
bstr p = *str;
bstr subparam = {0};
bstr subopt;
- int r = read_subparam(log, optname, &p, &subopt);
+ int r = read_subparam(log, optname, ":=,\\%\"'[]", &p, &subopt);
if (r < 0)
return r;
if (bstr_eatstart0(&p, "=")) {
- r = read_subparam(log, subopt, &p, &subparam);
+ r = read_subparam(log, subopt, ":=,\\%\"'[]", &p, &subparam);
if (r < 0)
return r;
}