Skip to content

Attrs() breaks escaped URLs #86

@hamid-elaosta

Description

@hamid-elaosta

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
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions