History

m_property: fix playlist property parsing

Disallow silly things like ${playlist//} and trailing slashes ${playlist/0/}.

Kacper Michajłow committed 1 year ago

Commit 95019fc1 parent 3c1ddc41 file · +4 −6Browse files

Unified · Split

options/m_property.c+4−6
@@ -617,19 +617,17 @@ int m_property_read_list(int action, void *arg, int count, · 616 unmodified lines
617 return M_PROPERTY_NOT_IMPLEMENTED;617 return M_PROPERTY_NOT_IMPLEMENTED;
618 }618 }
619 // This is expected of the form "123" or "123/rest"619 // This is expected of the form "123" or "123/rest"
620 char *next = strchr(ka->key, '/');620 char *end;
621 char *end = NULL;
622 const char *key_end = ka->key + strlen(ka->key);
623 long int item = strtol(ka->key, &end, 10);621 long int item = strtol(ka->key, &end, 10);
624 // not a number, trailing characters, etc.622 // not a number, trailing characters, etc.
625 if ((end != key_end || ka->key == key_end) && end != next)623 if (end == ka->key || (end[0] == '/' && !end[1]))
626 return M_PROPERTY_UNKNOWN;624 return M_PROPERTY_UNKNOWN;
627 if (item < 0 || item >= count)625 if (item < 0 || item >= count)
628 return M_PROPERTY_UNKNOWN;626 return M_PROPERTY_UNKNOWN;
629 if (next) {627 if (*end) {
630 // Sub-path628 // Sub-path
631 struct m_property_action_arg n_ka = *ka;629 struct m_property_action_arg n_ka = *ka;
632 n_ka.key = next + 1;630 n_ka.key = end + 1;
633 return get_item(item, M_PROPERTY_KEY_ACTION, &n_ka, ctx);631 return get_item(item, M_PROPERTY_KEY_ACTION, &n_ka, ctx);
634 } else {632 } else {
635 // Direct query633 // Direct query

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t