Fixed a bug where playlists that have spaces in their name were unusable

This commit is contained in:
Antoine Gersant 2017-09-24 20:09:44 -07:00
parent eab2fe7f7f
commit 7654d49246
2 changed files with 11 additions and 0 deletions

View file

@ -573,6 +573,11 @@ fn read_playlist(request: &mut Request, db: &DB) -> IronResult<Response> {
_ => return Err(Error::from(ErrorKind::MissingPlaylistName).into()),
};
let playlist_name = match percent_decode(playlist_name.as_bytes()).decode_utf8() {
Ok(s) => s,
Err(e) => return Err(Error::from(ErrorKind::EncodingError).into()),
};
let songs = playlist::read_playlist(&playlist_name, &username, db)?;
let result_json = serde_json::to_string(&songs);
let result_json = match result_json {
@ -595,6 +600,11 @@ fn delete_playlist(request: &mut Request, db: &DB) -> IronResult<Response> {
_ => return Err(Error::from(ErrorKind::MissingPlaylistName).into()),
};
let playlist_name = match percent_decode(playlist_name.as_bytes()).decode_utf8() {
Ok(s) => s,
Err(e) => return Err(Error::from(ErrorKind::EncodingError).into()),
};
playlist::delete_playlist(&playlist_name, &username, db)?;
Ok(Response::with(status::Ok))

View file

@ -48,6 +48,7 @@ error_chain! {
FileNotFound {}
MissingIndexVersion {}
MissingPlaylistName {}
EncodingError {}
}
}