diff options
author | Hans de Graaff <hans@degraaff.org> | 2021-09-10 11:23:01 +0200 |
---|---|---|
committer | Hans de Graaff <hans@degraaff.org> | 2021-09-10 11:23:01 +0200 |
commit | 1c5287f6c1d0580c64bd5599e8e5e30a11502ccf (patch) | |
tree | f448fbdee92d942e8dfa172580aab50d1e44f511 /dev-ruby/feed_parser | |
parent | dev-ruby/feed_parser: cleanup (diff) | |
download | graaff-1c5287f6c1d0580c64bd5599e8e5e30a11502ccf.tar.gz graaff-1c5287f6c1d0580c64bd5599e8e5e30a11502ccf.tar.bz2 graaff-1c5287f6c1d0580c64bd5599e8e5e30a11502ccf.zip |
dev-ruby/feed_parser: fix URI.open issue
Package-Manager: Portage-3.0.20, Repoman-3.0.3
Signed-off-by: Hans de Graaff <hans@degraaff.org>
Diffstat (limited to 'dev-ruby/feed_parser')
-rw-r--r-- | dev-ruby/feed_parser/feed_parser-0.3.5-r2.ebuild | 24 | ||||
-rw-r--r-- | dev-ruby/feed_parser/files/feed_parser-0.3.5-uri-open.patch | 74 |
2 files changed, 98 insertions, 0 deletions
diff --git a/dev-ruby/feed_parser/feed_parser-0.3.5-r2.ebuild b/dev-ruby/feed_parser/feed_parser-0.3.5-r2.ebuild new file mode 100644 index 00000000..4c4cdc72 --- /dev/null +++ b/dev-ruby/feed_parser/feed_parser-0.3.5-r2.ebuild @@ -0,0 +1,24 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 +USE_RUBY="ruby26 ruby27 ruby30" + +RUBY_FAKEGEM_EXTRADOC="README.md" + +RUBY_FAKEGEM_TASK_DOC="" +RUBY_FAKEGEM_RECIPE_TEST="rspec3" + +inherit ruby-fakegem + +DESCRIPTION="Rss and Atom feed parser built on top of Nokogiri" +HOMEPAGE="https://github.com/arttu/feed_parser" +LICENSE="MIT" + +KEYWORDS="~amd64" +SLOT="0" +IUSE="" + +PATCHES=( "${FILESDIR}/${P}-uri-open.patch" ) + +ruby_add_rdepend "dev-ruby/nokogiri" diff --git a/dev-ruby/feed_parser/files/feed_parser-0.3.5-uri-open.patch b/dev-ruby/feed_parser/files/feed_parser-0.3.5-uri-open.patch new file mode 100644 index 00000000..9532f0f9 --- /dev/null +++ b/dev-ruby/feed_parser/files/feed_parser-0.3.5-uri-open.patch @@ -0,0 +1,74 @@ +diff --git a/lib/feed_parser.rb b/lib/feed_parser.rb +index bb619e8..5697166 100644 +--- a/lib/feed_parser.rb ++++ b/lib/feed_parser.rb +@@ -54,7 +54,7 @@ def open_or_follow_redirect(feed_url) + @http_options[:redirect] = true if RUBY_VERSION >= '1.9' + + if ['http', 'https'].include?(uri.scheme) +- open(uri.to_s, @http_options) ++ URI.open(uri.to_s, @http_options) + else + raise FeedParser::InvalidURI.new("Only URIs with http or https protocol are supported") + end +diff --git a/spec/feed_parser_spec.rb b/spec/feed_parser_spec.rb +index d9651a7..fd99747 100644 +--- a/spec/feed_parser_spec.rb ++++ b/spec/feed_parser_spec.rb +@@ -33,39 +33,39 @@ def http_connection_options + + describe "#new" do + it "should forward given http options to the OpenURI" do +- FeedParser.any_instance.should_receive(:open).with("http://blog.example.com/feed/", http_connection_options.merge(:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE)).and_return(feed_xml) ++ URI.should_receive(:open).with("http://blog.example.com/feed/", http_connection_options.merge(:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE)).and_return(feed_xml) + fp = FeedParser.new(:url => "http://blog.example.com/feed/", :http => {:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE}) + fp.parse + end + + it "should fetch a feed by url" do +- FeedParser.any_instance.should_receive(:open).with("http://blog.example.com/feed/", http_connection_options).and_return(feed_xml) ++ URI.should_receive(:open).with("http://blog.example.com/feed/", http_connection_options).and_return(feed_xml) + fp = FeedParser.new({:url => "http://blog.example.com/feed/"}.merge(http_connection_options)) + fp.parse + end + + it "should fetch a feed using basic auth if auth embedded to the url" do +- FeedParser.any_instance.should_receive(:open).with("http://blog.example.com/feed/", http_connection_options.merge(:http_basic_authentication => ["user", "pass"])).and_return(feed_xml) ++ URI.should_receive(:open).with("http://blog.example.com/feed/", http_connection_options.merge(:http_basic_authentication => ["user", "pass"])).and_return(feed_xml) + fp = FeedParser.new({:url => "http://user:pass@blog.example.com/feed/"}.merge(http_connection_options)) + fp.parse + end + + it "should fetch a feed with only a user name embedded to the url" do +- FeedParser.any_instance.should_receive(:open).with("http://blog.example.com/feed/", http_connection_options.merge(:http_basic_authentication => ["user"])).and_return(feed_xml) ++ URI.should_receive(:open).with("http://blog.example.com/feed/", http_connection_options.merge(:http_basic_authentication => ["user"])).and_return(feed_xml) + fp = FeedParser.new({:url => "http://user@blog.example.com/feed/"}.merge(http_connection_options)) + fp.parse + end + + it "should follow redirect based on the exception message (even if OpenURI don't want to do it)" do +- FeedParser.any_instance.should_receive(:open).with("http://example.com/feed", http_connection_options).and_raise(RuntimeError.new("redirection forbidden: http://example.com/feed -> https://example.com/feed")) +- FeedParser.any_instance.should_receive(:open).with("https://example.com/feed", http_connection_options).and_return(feed_xml) ++ URI.should_receive(:open).with("http://example.com/feed", http_connection_options).and_raise(RuntimeError.new("redirection forbidden: http://example.com/feed -> https://example.com/feed")) ++ URI.should_receive(:open).with("https://example.com/feed", http_connection_options).and_return(feed_xml) + fp = FeedParser.new({:url => "http://example.com/feed"}.merge(http_connection_options)) + fp.parse + end + + it "should not follow redirect from a secure connection to a non-secure one" do +- FeedParser.any_instance.should_receive(:open).with("https://example.com/feed", http_connection_options).and_raise(RuntimeError.new("redirection forbidden: https://example.com/feed -> http://example.com/feed")) +- FeedParser.any_instance.should_not_receive(:open).with("http://example.com/feed", http_connection_options) ++ URI.should_receive(:open).with("https://example.com/feed", http_connection_options).and_raise(RuntimeError.new("redirection forbidden: https://example.com/feed -> http://example.com/feed")) ++ URI.should_not_receive(:open).with("http://example.com/feed", http_connection_options) + lambda { + fp = FeedParser.new({:url => "https://example.com/feed"}.merge(http_connection_options)) + fp.parse +@@ -73,7 +73,7 @@ def http_connection_options + end + + it "should raise an error unless retrieved XML is not an RSS or an ATOM feed" do +- FeedParser.any_instance.should_receive(:open).with("http://example.com/blog/feed/invalid.xml", http_connection_options).and_return("foo bar") ++ URI.should_receive(:open).with("http://example.com/blog/feed/invalid.xml", http_connection_options).and_return("foo bar") + lambda { + fp = FeedParser.new({:url => "http://example.com/blog/feed/invalid.xml"}.merge(http_connection_options)) + fp.parse |