Package list feed2imap / d878398
Merge tag 'upstream/1.2.5' Upstream version 1.2.5 # gpg: Signature made Dom 10 Mai 2015 20:46:25 BRT using RSA key ID CD460BDE # gpg: Good signature from "Antonio Terceiro <terceiro@softwarelivre.org>" # gpg: aka "Antonio Terceiro <terceiro@dcc.ufba.br>" # gpg: aka "Antonio Terceiro <terceiro@colivre.coop.br>" # gpg: aka "Antonio Terceiro <terceiro@debian.org>" # gpg: aka "Antonio Terceiro <terceiro@cs.ubc.ca>" # gpg: aka "Antonio Terceiro <antonio.terceiro@linaro.org>" Antonio Terceiro 6 years ago
3 changed file(s) with 16 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
1717 =end
1818
1919 # Feed2Imap version
20 F2I_VERSION = '1.2.4'
20 F2I_VERSION = '1.2.5'
2121 F2I_WARNFETCHTIME = 10
2222
2323 require 'feed2imap/config'
9898 htmlpart.body.gsub!(/(<img[^>]+)src="(\S+?\/([^\/]+?\.(png|gif|jpe?g)))"([^>]*>)/i) do |match|
9999 # $2 contains url, $3 the image name, $4 the image extension
100100 begin
101 image = Base64.encode64(HTTPFetcher::fetch($2, Time.at(0)).chomp) + "\n"
101 fetcher = HTTPFetcher.new
102 image = Base64.encode64(fetcher.fetch($2, Time.at(0)).chomp) + "\n"
102103 cid = "#{Digest::MD5.hexdigest($2)}@#{config.hostname}"
103104 if not cids.include?(cid)
104105 cids << cid
88 def test_get_https
99 s = ''
1010 assert_nothing_raised do
11 s = HTTPFetcher::fetch('https://linuxfr.org/pub/', Time::at(0))
11 s = fetcher.fetch('https://linuxfr.org/pub/', Time::at(0))
1212 end
1313 assert(s.length > 20)
1414 end
2020 def test_get_httpnotmodif
2121 s = 'aaa'
2222 assert_nothing_raised do
23 s = HTTPFetcher::fetch('http://www.lucas-nussbaum.net/feed2imap_tests/notmodified.php', Time::new())
23 s = fetcher.fetch('http://www.lucas-nussbaum.net/feed2imap_tests/notmodified.php', Time::new())
2424 end
2525 assert_nil(s)
2626 end
2828 def test_get_redir1
2929 s = 'aaa'
3030 assert_nothing_raised do
31 s = HTTPFetcher::fetch("http://www.lucas-nussbaum.net/feed2imap_tests/redir.php?redir=#{MAXREDIR}", Time::at(0))
31 s = fetcher.fetch("http://www.lucas-nussbaum.net/feed2imap_tests/redir.php?redir=#{MAXREDIR}", Time::at(0))
3232 end
3333 assert_equal('OK', s)
3434 end
3636 def test_get_redir2
3737 s = ''
3838 assert_raise(RuntimeError) do
39 s = HTTPFetcher::fetch("http://www.lucas-nussbaum.net/feed2imap_tests/redir.php?redir=#{MAXREDIR + 1}", Time::at(0))
39 s = fetcher.fetch("http://www.lucas-nussbaum.net/feed2imap_tests/redir.php?redir=#{MAXREDIR + 1}", Time::at(0))
4040 end
4141 end
4242
4343 def test_httpauth
4444 s = ''
4545 assert_nothing_raised do
46 s = HTTPFetcher::fetch("http://aaa:bbb@ensilinx1.imag.fr/~lucas/f2i_redirauth.php", Time::at(0))
46 s = fetcher.fetch("http://aaa:bbb@ensilinx1.imag.fr/~lucas/f2i_redirauth.php", Time::at(0))
4747 end
4848 assert_equal("Login: aaa / Password: bbb \n", s)
4949 end
5151 def test_redirauth
5252 s = ''
5353 assert_nothing_raised do
54 s = HTTPFetcher::fetch("http://aaa:bbb@ensilinx1.imag.fr/~lucas/f2i_redirauth.php?redir=1", Time::at(0))
54 s = fetcher.fetch("http://aaa:bbb@ensilinx1.imag.fr/~lucas/f2i_redirauth.php?redir=1", Time::at(0))
5555 end
5656 assert_equal("Login: aaa / Password: bbb \n", s)
5757 end
5959 def test_notfound
6060 s = ''
6161 assert_raises(RuntimeError) do
62 s = HTTPFetcher::fetch("http://ensilinx1.imag.fr/~lucas/notfound.html", Time::at(0))
62 s = fetcher.fetch("http://ensilinx1.imag.fr/~lucas/notfound.html", Time::at(0))
6363 end
6464 end
65
66 private
67
68 def fetcher
69 HTTPFetcher.new
70 end
6571 end