summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Terceiro <terceiro@softwarelivre.org>2015-05-10 20:40:19 -0300
committerAntonio Terceiro <terceiro@softwarelivre.org>2015-05-10 20:41:41 -0300
commit4614e1fa4ff4cb5d7442f680a053298e0cc80819 (patch)
treeee38185edcad6f4aa89ab88a6dd863e81ab4f70c
parente6744a2aac310bff2680207845d121a42f04209b (diff)
downloadfeed2imap-4614e1fa4ff4cb5d7442f680a053298e0cc80819.tar.gz
feed2imap-4614e1fa4ff4cb5d7442f680a053298e0cc80819.tar.bz2
feed2imap-4614e1fa4ff4cb5d7442f680a053298e0cc80819.zip
Fix regression in `include-images` option
test/tc_httpfetcher.rb can't still be re-enabled because it hits the network, and a hostname that is no longer valid.
-rwxr-xr-xfeed2imap-test1
-rw-r--r--lib/feed2imap/itemtomail.rb3
-rwxr-xr-xtest/tc_httpfetcher.rb20
3 files changed, 16 insertions, 8 deletions
diff --git a/feed2imap-test b/feed2imap-test
index e8424b5..c8dd6c2 100755
--- a/feed2imap-test
+++ b/feed2imap-test
@@ -20,6 +20,7 @@ case ARGV.length
when 0
config_data = <<EOF
cache: #{cache}
+include-images: true
feeds:
- name: CNPQ
url: http://www.cnpq.br/web/guest/noticias/-/asset_publisher/6QsO/rss?p_p_cacheability=cacheLevelPage
diff --git a/lib/feed2imap/itemtomail.rb b/lib/feed2imap/itemtomail.rb
index fcf8f8b..455a136 100644
--- a/lib/feed2imap/itemtomail.rb
+++ b/lib/feed2imap/itemtomail.rb
@@ -99,7 +99,8 @@ def item_to_mail(config, item, id, updated, from = 'Feed2Imap', inline_images =
htmlpart.body.gsub!(/(<img[^>]+)src="(\S+?\/([^\/]+?\.(png|gif|jpe?g)))"([^>]*>)/i) do |match|
# $2 contains url, $3 the image name, $4 the image extension
begin
- image = Base64.encode64(HTTPFetcher::fetch($2, Time.at(0)).chomp) + "\n"
+ fetcher = HTTPFetcher.new
+ image = Base64.encode64(fetcher.fetch($2, Time.at(0)).chomp) + "\n"
cid = "#{Digest::MD5.hexdigest($2)}@#{config.hostname}"
if not cids.include?(cid)
cids << cid
diff --git a/test/tc_httpfetcher.rb b/test/tc_httpfetcher.rb
index d44b3ee..e904086 100755
--- a/test/tc_httpfetcher.rb
+++ b/test/tc_httpfetcher.rb
@@ -9,7 +9,7 @@ class HttpFetcherTest < Test::Unit::TestCase
def test_get_https
s = ''
assert_nothing_raised do
- s = HTTPFetcher::fetch('https://linuxfr.org/pub/', Time::at(0))
+ s = fetcher.fetch('https://linuxfr.org/pub/', Time::at(0))
end
assert(s.length > 20)
end
@@ -21,7 +21,7 @@ class HttpFetcherTest < Test::Unit::TestCase
def test_get_httpnotmodif
s = 'aaa'
assert_nothing_raised do
- s = HTTPFetcher::fetch('http://www.lucas-nussbaum.net/feed2imap_tests/notmodified.php', Time::new())
+ s = fetcher.fetch('http://www.lucas-nussbaum.net/feed2imap_tests/notmodified.php', Time::new())
end
assert_nil(s)
end
@@ -29,7 +29,7 @@ class HttpFetcherTest < Test::Unit::TestCase
def test_get_redir1
s = 'aaa'
assert_nothing_raised do
- s = HTTPFetcher::fetch("http://www.lucas-nussbaum.net/feed2imap_tests/redir.php?redir=#{MAXREDIR}", Time::at(0))
+ s = fetcher.fetch("http://www.lucas-nussbaum.net/feed2imap_tests/redir.php?redir=#{MAXREDIR}", Time::at(0))
end
assert_equal('OK', s)
end
@@ -37,14 +37,14 @@ class HttpFetcherTest < Test::Unit::TestCase
def test_get_redir2
s = ''
assert_raise(RuntimeError) do
- s = HTTPFetcher::fetch("http://www.lucas-nussbaum.net/feed2imap_tests/redir.php?redir=#{MAXREDIR + 1}", Time::at(0))
+ s = fetcher.fetch("http://www.lucas-nussbaum.net/feed2imap_tests/redir.php?redir=#{MAXREDIR + 1}", Time::at(0))
end
end
def test_httpauth
s = ''
assert_nothing_raised do
- s = HTTPFetcher::fetch("http://aaa:bbb@ensilinx1.imag.fr/~lucas/f2i_redirauth.php", Time::at(0))
+ s = fetcher.fetch("http://aaa:bbb@ensilinx1.imag.fr/~lucas/f2i_redirauth.php", Time::at(0))
end
assert_equal("Login: aaa / Password: bbb \n", s)
end
@@ -52,7 +52,7 @@ class HttpFetcherTest < Test::Unit::TestCase
def test_redirauth
s = ''
assert_nothing_raised do
- s = HTTPFetcher::fetch("http://aaa:bbb@ensilinx1.imag.fr/~lucas/f2i_redirauth.php?redir=1", Time::at(0))
+ s = fetcher.fetch("http://aaa:bbb@ensilinx1.imag.fr/~lucas/f2i_redirauth.php?redir=1", Time::at(0))
end
assert_equal("Login: aaa / Password: bbb \n", s)
end
@@ -60,7 +60,13 @@ class HttpFetcherTest < Test::Unit::TestCase
def test_notfound
s = ''
assert_raises(RuntimeError) do
- s = HTTPFetcher::fetch("http://ensilinx1.imag.fr/~lucas/notfound.html", Time::at(0))
+ s = fetcher.fetch("http://ensilinx1.imag.fr/~lucas/notfound.html", Time::at(0))
end
end
+
+ private
+
+ def fetcher
+ HTTPFetcher.new
+ end
end