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/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"
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 @@
+
+
The post Mitä asiakkaamme ajattelevat meistä? appeared first on SC5 Blog.
+]]> +The post Tribute to Jyväskylä, City of Lights appeared first on SC5 Blog.
+]]>