~nbsp/mus#19: 
rust-mpd has broken protocol parsing

mus play fails on my library:

ckie@cookiemonster ~ -> mus play

thread 'main' panicked at src/server.rs:77:38: called `Result::unwrap()` 
on an `Err` value: Parse(BadPair)

note: run with `RUST_BACKTRACE=1` environment variable to display a 
backtrace

i have a song with filename " - medicago - leastfavorite! VIP.mp3"

the initial space breaks it when parsing the file list, mpd sends:

file:  - medicago - leastfavorite! VIP.mp3

note the doublespace

fix in rust-mpd:

modified   src/reply.rs
@@ -26,9 +26,9 @@ impl FromStr for Reply {
          } else if let Ok(ack) = s.parse::<ServerError>() {
              Ok(Reply::Ack(ack))
          } else {
-            let mut splits = s.splitn(2, ':');
+            let mut splits = s.splitn(2, ": ");
              match (splits.next(), splits.next()) {
-                (Some(a), Some(b)) => Ok(Reply::Pair(a.to_owned(), 
b.trim().to_owned())),
+                (Some(a), Some(b)) => Ok(Reply::Pair(a.to_owned(), 
b.to_owned())),
                  _ => Err(ParseError::BadPair),
              }
          }

iirc rust-mpd is abandoned

:3

Status
REPORTED
Submitter
mei ckie
Assigned to
No-one
Submitted
a month ago
Updated
a month ago
Labels
No labels applied.