Fixed a bug where playlists that have spaces in their name were unusable
This commit is contained in:
parent
eab2fe7f7f
commit
7654d49246
2 changed files with 11 additions and 0 deletions
10
src/api.rs
10
src/api.rs
|
@ -573,6 +573,11 @@ fn read_playlist(request: &mut Request, db: &DB) -> IronResult<Response> {
|
||||||
_ => return Err(Error::from(ErrorKind::MissingPlaylistName).into()),
|
_ => 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 songs = playlist::read_playlist(&playlist_name, &username, db)?;
|
||||||
let result_json = serde_json::to_string(&songs);
|
let result_json = serde_json::to_string(&songs);
|
||||||
let result_json = match result_json {
|
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()),
|
_ => 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)?;
|
playlist::delete_playlist(&playlist_name, &username, db)?;
|
||||||
|
|
||||||
Ok(Response::with(status::Ok))
|
Ok(Response::with(status::Ok))
|
||||||
|
|
|
@ -48,6 +48,7 @@ error_chain! {
|
||||||
FileNotFound {}
|
FileNotFound {}
|
||||||
MissingIndexVersion {}
|
MissingIndexVersion {}
|
||||||
MissingPlaylistName {}
|
MissingPlaylistName {}
|
||||||
|
EncodingError {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue