Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle ambiguous sticker names and values #2166

Open
h7x4 opened this issue Dec 13, 2024 · 4 comments
Open

Handle ambiguous sticker names and values #2166

h7x4 opened this issue Dec 13, 2024 · 4 comments

Comments

@h7x4
Copy link

h7x4 commented Dec 13, 2024

There is an edgecase for stickers with names and values containing =, making the server output hard to parse.

$ nc localhost 6600
OK MPD 0.24.0
sticker set playlist TestPlaylist "test=1" "value=2"
OK
sticker list playlist TestPlaylist
sticker: test=1=value=2
OK

First solution that comes to mind would be to wrap the name and value in quotes, but then you could maybe put "=" inside your string or something (I guess we could escape quotes as well?). Not sure what the best solution is here. Newlines maybe?

I feel like this is in the grey area of being a bug, considering it's up to the client developer to choose sensible tag names. But one client might interfere with another, so maybe it should be considered so.

@geneticdrift
Copy link
Contributor

Adding for reference:
The issue of escaping = in sticker names was raised in the PR and was left out eventually.

This is the relevant part of a longer comment:

"escape sticker name" - I'm not happy with this one. The escaping syntax for sticker names is not documented, and I'd rather restrict the allowed sticker names than adding some escaping rules. I mean, why would anybody really need = in a sticker name? Not restricting sticker names might have been an oversight in the initial design.

Agree. Not a significant issue.

@jcorporation
Copy link
Member

jcorporation commented Dec 18, 2024

I have already some pull requests for improved sticker handling open. After they are merged, I could look into this. I think restricting the sticker names is the best approach. Should we only disallow = or should we allow only [a-zA-Z0-9] and some special charakters like .-_?

@geneticdrift
Copy link
Contributor

restricting the sticker names is the best approach

Could be a backward compatibility problem if sticker names that are already in the database become invalid.

So maybe just documenting the restrictions and not enforcing them?

From the docs:

Client developers should create a standard for common sticker names, to ensure interoperability.

This never happened as far as I know, so clients may only be concerned with their own sticker names.

New restrictions can then be applied only to MPD officially standardized sticker names if and when that happens.

@jcorporation
Copy link
Member

jcorporation commented Dec 18, 2024

I had tried to create a standard: https://github.com/jcorporation/mpd-stickers

At the moment it is only a collection of used sticker namens.

As MPD has now a feature to enable specific protocol features, it can be implemented as opt-in for new clients.

#2123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants