From 4ee1bc63204ed9bcd7dccbc893f80fef76e26b47 Mon Sep 17 00:00:00 2001 From: 5minpause Date: Tue, 12 May 2015 10:16:21 +0200 Subject: [PATCH] Changes RSS item creation to prevent encoding errors SimpleRss is unreliable with parsing RSS feeds that contain German Umlauts. For example this feed http://www.lauffeuer-lb.de/api/v2/articles.xml can't be parsed by SimpleRss. Discourse's logs are full of ``` Job exception: Wrapped Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8 Job exception: incompatible character encodings: ASCII-8BIT and UTF-8 ``` The embedding fails because the feed can't be parsed. This change forces the encoding (using #scrub) which prevents the numerous encoding errors. --- app/jobs/scheduled/poll_feed.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/jobs/scheduled/poll_feed.rb b/app/jobs/scheduled/poll_feed.rb index 8c0c8eb0185..920c2161a9f 100644 --- a/app/jobs/scheduled/poll_feed.rb +++ b/app/jobs/scheduled/poll_feed.rb @@ -86,11 +86,15 @@ module Jobs end def content - @article_rss_item.content || @article_rss_item.description + if @article_rss_item.content + @article_rss_item.content.scrub + else + @article_rss_item.description.scrub + end end def title - @article_rss_item.title + @article_rss_item.title.scrub end def user