Skip to content

Commit

Permalink
fix: decode html entities in playlist description
Browse files Browse the repository at this point in the history
  • Loading branch information
Joris Mertz committed Jun 17, 2024
1 parent ba62607 commit e353395
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions spotify_player/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ ttl_cache = "0.5.1"
clap_complete = "4.5.1"
which = "6.0.1"
fuzzy-matcher = { version = "0.3.7", optional = true }
html-escape = "0.2.13"

[target.'cfg(any(target_os = "windows", target_os = "macos"))'.dependencies.winit]
version = "0.30.0"
Expand Down
4 changes: 2 additions & 2 deletions spotify_player/src/state/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use rspotify::model::CurrentPlaybackContext;
pub use rspotify::model::{AlbumId, ArtistId, Id, PlaylistId, TrackId, UserId};

use crate::utils::map_join;
use html_escape::decode_html_entities;
use serde::{Deserialize, Serialize};
use std::borrow::Cow;

Expand Down Expand Up @@ -403,10 +404,9 @@ impl From<rspotify_model::SimplifiedPlaylist> for Playlist {
impl From<rspotify_model::FullPlaylist> for Playlist {
fn from(playlist: rspotify_model::FullPlaylist) -> Self {
// remove HTML tags from the description
// TODO: may also need to do HTML escaping here
let re = regex::Regex::new("(<.*?>|</.*?>)").expect("valid regex");
let desc = playlist.description.unwrap_or_default();
let desc = re.replace_all(&desc, "").to_string();
let desc = decode_html_entities(&re.replace_all(&desc, "")).to_string();

Self {
id: playlist.id,
Expand Down

0 comments on commit e353395

Please sign in to comment.