onebox 1.8.6 → 1.8.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 389009d0633bfd3396fba23cb000eff26cb019d5
4
- data.tar.gz: b2fac0d0854c26b0be21586636488f64936fb7c9
3
+ metadata.gz: ef00f44fb0438b70ec1b8cbe01573eb2ea5601b5
4
+ data.tar.gz: b6753a95e16de7f6d0a7b47c888d8e7683b48295
5
5
  SHA512:
6
- metadata.gz: 494c648079d4ed949fad65c1a56f1b63d871fb5a49450c53ddc9242264c9038a9bc499d980d29636612f6089853e86cb7989da2ef7d039e45a3787e7a1d68ba4
7
- data.tar.gz: 45b227ce833a00abd7783120aeb55df26cb98323d9be012c9f3d1eaf1453ec71c554e41156828ce28b322f130c5e43be1f376936fe0981a6870a27919b612eed
6
+ metadata.gz: b4f23e877c9f42bf9fa07d50b93f56fc8955aa22a6bd1a34d3a581c74bc796870024dcc8379689b8bcdccfb34b061d2ffa3f834b79d087f73ab1a75054da5478
7
+ data.tar.gz: d826e5abd61a33dbcab2cff3ac9af1a50b3a63d40b2151398617ea7b0b56c975509e0bf17f3adac05cc2a5e9bcb3bc4f7671a9a0e0e15366f665530013b7ac37
@@ -22,6 +22,7 @@ module Onebox
22
22
  allowed_ports: [80, 443],
23
23
  allowed_schemes: ["http", "https"],
24
24
  sanitize_config: Sanitize::Config::ONEBOX,
25
+ redirect_limit: 5
25
26
  }
26
27
 
27
28
  @@options = DEFAULTS
@@ -19,6 +19,9 @@ module Onebox
19
19
  end
20
20
 
21
21
  def self.fetch_response(location, limit=5, domain=nil, headers=nil)
22
+
23
+ limit = Onebox.options.redirect_limit if limit > Onebox.options.redirect_limit
24
+
22
25
  raise Net::HTTPError.new('HTTP redirect too deep', location) if limit == 0
23
26
 
24
27
  uri = URI(location)
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.8.6"
2
+ VERSION = "1.8.7"
3
3
  end
@@ -84,10 +84,15 @@ describe Onebox::Engine::WhitelistedGenericOnebox do
84
84
  end
85
85
 
86
86
  describe 'to_html' do
87
+ after(:each) do
88
+ Onebox.options = Onebox::DEFAULTS
89
+ end
90
+
91
+ let(:original_link) { "http://www.dailymail.co.uk/pages/live/articles/news/news.html?in_article_id=479146&in_page_id=1770" }
92
+ let(:redirect_link) { 'http://www.dailymail.co.uk/news/article-479146/Brutality-justice-The-truth-tarred-feathered-drug-dealer.html' }
93
+
87
94
  before do
88
95
  described_class.whitelist = %w(dailymail.co.uk discourse.org)
89
- original_link = "http://www.dailymail.co.uk/pages/live/articles/news/news.html?in_article_id=479146&in_page_id=1770"
90
- redirect_link = 'http://www.dailymail.co.uk/news/article-479146/Brutality-justice-The-truth-tarred-feathered-drug-dealer.html'
91
96
  FakeWeb.register_uri(
92
97
  :get,
93
98
  original_link,
@@ -95,13 +100,18 @@ describe Onebox::Engine::WhitelistedGenericOnebox do
95
100
  location: redirect_link
96
101
  )
97
102
  fake(redirect_link, response('dailymail'))
98
- onebox = described_class.new(original_link)
99
- @html = onebox.to_html
100
103
  end
101
- let(:html) { @html }
102
104
 
103
105
  it "follows redirects and includes the summary" do
104
- expect(html).to include("It was the most chilling image of the week")
106
+ Onebox.options = { redirect_limit: 2 }
107
+ onebox = described_class.new(original_link)
108
+ expect(onebox.to_html).to include("It was the most chilling image of the week")
109
+ end
110
+
111
+ it "recives an error with too many redirects" do
112
+ Onebox.options = { redirect_limit: 1 }
113
+ onebox = described_class.new(original_link)
114
+ expect(onebox.to_html).to be_nil
105
115
  end
106
116
  end
107
117
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onebox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.6
4
+ version: 1.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joanna Zeta
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-05-17 00:00:00.000000000 Z
13
+ date: 2017-05-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json