From 5cd0a3c451abb3aa1e29bd408cd866cde45ee2ab Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Tue, 10 Apr 2018 07:01:55 +0300 Subject: [PATCH] Fix the things I broke in b74dbb74bb0e7941b0ca0f3e8dd6b0fa576f9f3a Someone really needs to restrict my access to anything that involves transistors when I am sleep deprived. --- hammond-data/src/models/new_episode.rs | 7 ++++--- hammond-data/src/models/new_podcast.rs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hammond-data/src/models/new_episode.rs b/hammond-data/src/models/new_episode.rs index 9df4229..d456ef1 100644 --- a/hammond-data/src/models/new_episode.rs +++ b/hammond-data/src/models/new_episode.rs @@ -234,12 +234,13 @@ impl NewEpisodeMinimal { // TODO: TryInto is stabilizing in rustc v1.26! pub(crate) fn into_new_episode(self, item: &rss::Item) -> NewEpisode { let length = item.enclosure().and_then(|x| x.length().parse().ok()); - let description = item.description().map(|s| { - ammonia::Builder::new() + let description = item.description().and_then(|s| { + let sanitized_html = ammonia::Builder::new() // Remove `rel` attributes from `` tags .link_rel(None) - .clean(chan.description().trim()) + .clean(s.trim()) .to_string(); + Some(sanitized_html) }); NewEpisodeBuilder::default() diff --git a/hammond-data/src/models/new_podcast.rs b/hammond-data/src/models/new_podcast.rs index 38f31b7..e370fef 100644 --- a/hammond-data/src/models/new_podcast.rs +++ b/hammond-data/src/models/new_podcast.rs @@ -98,7 +98,7 @@ impl NewPodcast { // Try to get the itunes img first let itunes_img = chan.itunes_ext() - .and_then(|s| s.image().trim()) + .and_then(|s| s.image().map(|url| url.trim())) .map(|s| s.to_owned()); // If itunes is None, try to get the channel.image from the rss spec let image_uri = itunes_img.or_else(|| chan.image().map(|s| s.url().trim().to_owned()));