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

Attrs() breaks escaped URLs #86

Open
hamid-elaosta opened this issue Nov 30, 2023 · 0 comments
Open

Attrs() breaks escaped URLs #86

hamid-elaosta opened this issue Nov 30, 2023 · 0 comments

Comments

@hamid-elaosta
Copy link

Experimenting with some encoded URLs (using gompd v2.3.0 tag) I found that addid was breaking the URLs it sends to MPD while add was not.

After some digging I found that the way Attrs() passes the command to cmd.client.cmd is different to the way OK() does it.

Ultimately, this results in printfLine trying to handle escaped characters in URLs as Go string formatting directives and complaining that they're missing in the final formatted string.

Example of problem URL before fix: https://...?text=Sorry%!C(MISSING)+I+couldn%!t(MISSING)+understand+that
An example of a problem URL after fix: https://...?text=Sorry%2C+I+couldn%27t+understand+that

The fix appears to be, to call cmd.client.cmd the same way it is called elsewhere:

diff --git a/mpd/response.go b/mpd/response.go
index 3f1505b..5289fea 100644
--- a/mpd/response.go
+++ b/mpd/response.go
@@ -53,7 +53,7 @@ func (cmd *Command) OK() error {
 
 // Attrs sends command to server and reads attributes returned in response.
 func (cmd *Command) Attrs() (Attrs, error) {
-       id, err := cmd.client.cmd(cmd.cmd)
+       id, err := cmd.client.cmd("%v", cmd.cmd)
        if err != nil {
                return nil, err
        }
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

1 participant