From ee4736744da06ff4fc3d00e3fc1cf979c24601d8 Mon Sep 17 00:00:00 2001 From: Tero Tilus Date: Fri, 3 Oct 2014 00:36:51 +0300 Subject: [PATCH 1/2] Do not force content string encodings, keep them as they are --- lib/simple-rss.rb | 14 ++++----- test/base/base_test.rb | 11 ++++++++ test/data/rss20_utf8.xml | 61 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 test/data/rss20_utf8.xml diff --git a/lib/simple-rss.rb b/lib/simple-rss.rb index fc22b52..3a80506 100644 --- a/lib/simple-rss.rb +++ b/lib/simple-rss.rb @@ -151,13 +151,13 @@ def clean_tag(tag) tag.to_s.gsub(':','_').intern end - def unescape(content) - if content.respond_to?(:force_encoding) && content.force_encoding("binary") =~ /([^-_.!~*'()a-zA-Z\d;\/?:@&=+$,\[\]]%)/n then - CGI.unescape(content).gsub(/()/,'').strip - else - content.gsub(/()/,'').strip - end - end + def unescape(content) + if content =~ /([^-_.!~*'()a-zA-Z\d;\/?:@&=+$,\[\]]%)/ then + CGI.unescape(content) + else + content + end.gsub(/()/,'').strip + end end class SimpleRSSError < StandardError diff --git a/test/base/base_test.rb b/test/base/base_test.rb index a40c57d..b19d5a2 100644 --- a/test/base/base_test.rb +++ b/test/base/base_test.rb @@ -1,8 +1,10 @@ +# -*- coding: utf-8 -*- require 'test_helper' class BaseTest < Test::Unit::TestCase def setup @rss09 = SimpleRSS.parse open(File.dirname(__FILE__) + '/../data/rss09.rdf') @rss20 = SimpleRSS.parse open(File.dirname(__FILE__) + '/../data/rss20.xml') + @rss20_utf8 = SimpleRSS.parse open(File.dirname(__FILE__) + '/../data/rss20_utf8.xml') @media_rss = SimpleRSS.parse open(File.dirname(__FILE__) + '/../data/media_rss.xml') @atom = SimpleRSS.parse open(File.dirname(__FILE__) + '/../data/atom.xml') end @@ -69,4 +71,13 @@ def test_atom def test_bad_feed assert_raise(SimpleRSSError) { SimpleRSS.parse(open(File.dirname(__FILE__) + '/../data/not-rss.xml')) } end + + def test_rss_utf8 + assert_equal 2, @rss20_utf8.items.size + assert_equal "SC5 Blog", @rss20_utf8.title + assert_equal Encoding::UTF_8, @rss20_utf8.title.encoding + item = @rss20_utf8.items.first + assert_equal "Mitä asiakkaamme ajattelevat meistä?", item.title + assert_equal Encoding::UTF_8, item.title.encoding + end end diff --git a/test/data/rss20_utf8.xml b/test/data/rss20_utf8.xml new file mode 100644 index 0000000..fedb0f1 --- /dev/null +++ b/test/data/rss20_utf8.xml @@ -0,0 +1,61 @@ + + + + + SC5 Blog + + http://sc5.io/blog + HTML5 expertise + Wed, 01 Oct 2014 09:52:48 +0000 + fi-FI + hourly + 1 + http://wordpress.org/?v=4.0 + + Mitä asiakkaamme ajattelevat meistä? + http://sc5.io/blog/2014/09/mita-asiakkaamme-ajattelevat-meista/ + http://sc5.io/blog/2014/09/mita-asiakkaamme-ajattelevat-meista/#comments + Mon, 29 Sep 2014 13:19:37 +0000 + + + + + http://sc5.io/blog/?p=2818 + Toteutimme yhdessä MicroMedian kanssa asiakastyytyväisyystutkimuksen, jossa tiedustelimme asiakkaidemme näkemyksiä toimintatavoistamme. Voimme ylpeänä kertoa, että asiakkaamme tykkäsivät työmme jäljestä. Mutta mihin asiakamme olivat meissä erityisen tyytyväisiä? Vastauksissa korostuivat työntekijöidemme osaaminen ja ammattitaito. Lisäksi kehuttiin kykyämme nähdä... Read More

+

The post Mitä asiakkaamme ajattelevat meistä? appeared first on SC5 Blog.

+]]>
+ http://sc5.io/blog/2014/09/mita-asiakkaamme-ajattelevat-meista/feed/ + 0 +
+ + Tribute to Jyväskylä, City of Lights + http://sc5.io/blog/2014/09/tribute-to-jyvaskyla-city-of-lights/ + http://sc5.io/blog/2014/09/tribute-to-jyvaskyla-city-of-lights/#comments + Thu, 25 Sep 2014 10:36:20 +0000 + + + + + + + + + + + + http://sc5.io/blog/?p=2886 + In Finland the winters are dark so artificial, energy-efficient lights are needed. Good lighting not only boosts enjoyment and the quality of life, but can be a form of art itself. Jyväskylä is a forerunner... Read More

+

The post Tribute to Jyväskylä, City of Lights appeared first on SC5 Blog.

+]]>
+ http://sc5.io/blog/2014/09/tribute-to-jyvaskyla-city-of-lights/feed/ + 0 +
+
+
From 8ed777b1604c92383e422aa407f1c2cd723c6658 Mon Sep 17 00:00:00 2001 From: Tero Tilus Date: Fri, 3 Oct 2014 00:51:55 +0300 Subject: [PATCH 2/2] Bump version --- simple-rss.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simple-rss.gemspec b/simple-rss.gemspec index 0e5b5c4..24bee17 100644 --- a/simple-rss.gemspec +++ b/simple-rss.gemspec @@ -1,8 +1,8 @@ Gem::Specification.new do |s| s.name = "simple-rss" - s.version = "1.2.3" + s.version = "1.3.2" s.version = "#{s.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS'] - s.date = "2010-07-06" + s.date = "2014-10-03" s.summary = "A simple, flexible, extensible, and liberal RSS and Atom reader for Ruby. It is designed to be backwards compatible with the standard RSS parser, but will never do RSS generation." s.email = "lucas@rufy.com" s.homepage = "http://github.com/cardmagic/simple-rss"