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
617617 return M_PROPERTY_NOT_IMPLEMENTED;
618618 }
619619 // This is expected of the form "123" or "123/rest"
620− char *next = strchr(ka->key, '/');
621− char *end = NULL;
622− const char *key_end = ka->key + strlen(ka->key);
620+ char *end;
623621 long int item = strtol(ka->key, &end, 10);
624622 // 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]))
626624 return M_PROPERTY_UNKNOWN;
627625 if (item < 0 || item >= count)
628626 return M_PROPERTY_UNKNOWN;
629− if (next) {
627+ if (*end) {
630628 // Sub-path
631629 struct m_property_action_arg n_ka = *ka;
632− n_ka.key = next + 1;
630+ n_ka.key = end + 1;
633631 return get_item(item, M_PROPERTY_KEY_ACTION, &n_ka, ctx);
634632 } else {
635633 // 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