@@ -478,13 +478,14 @@ func TestQuote(t *testing.T) {
478478 }{
479479 {`test.ogg` , `"test.ogg"` },
480480 {`test "song".ogg` , `"test \"song\".ogg"` },
481- {`test with 'single' and "double" quotes` , `"test with \\'single\\' and \"double\" quotes"` },
481+ {`test with 'single' and "double" quotes` , `"test with \'single\' and \"double\" quotes"` },
482+ {`escape \"escaped\"` , `"escape \\\"escaped\\\""` },
483+ {`just a \` , `"just a \\"` },
482484 {`04 - ILL - DECAYED LOVE feat.℃iel.ogg` , `"04 - ILL - DECAYED LOVE feat.℃iel.ogg"` },
483485 // Test case provided at https://www.musicpd.org/doc/html/protocol.html#escaping-string-values.
484- // NB: it deviates from the original case in that the single quote is left unescaped because the escaping is
485- // done by quote(). With this approach, the user should only take care of backslash-escaping double quotes
486- // inside a double-quoted literal.
487- {`(Artist == "foo'bar\"")` , `"(Artist == \"foo\\'bar\\\"\")"` },
486+ // NB: we don't support quoting in the "protocol level" mode, hence single quotes get the same treatment as
487+ // double quotes and there are 3 backslashes before the single quote, too.
488+ {`(Artist == "foo\'bar\"")` , `"(Artist == \"foo\\\'bar\\\"\")"` },
488489 }
489490 // Run tests
490491 for _ , test := range quoteTests {
@@ -495,8 +496,8 @@ func TestQuote(t *testing.T) {
495496}
496497
497498func TestQuoteArgs (t * testing.T ) {
498- input := []string {`Artist` , `Nightingale` , `Title` , `\ "Don't Go Away\ "` }
499- expected := `"Artist" "Nightingale" "Title" "\\\ "Don\\ 't Go Away\\ \""`
499+ input := []string {`Artist` , `Nightingale` , `Title` , `"Don't Go Away"` }
500+ expected := `"Artist" "Nightingale" "Title" "\"Don\'t Go Away\""`
500501 if got := quoteArgs (input ); got != expected {
501502 t .Errorf ("quoteArgs(%v) returned %s; expected %s" , input , got , expected )
502503 }
0 commit comments