gompd
gompd copied to clipboard
Attrs() breaks escaped URLs
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
}