onebox 1.8.10 → 1.8.11
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9fdd8decf0ce95f8a5c44381780bbc8d66e8c50
|
4
|
+
data.tar.gz: 8147a14fb6fd5990ace1e5cf2bcefa928a1e0ba9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0c8feea7c6a688a416f524d33d981377b5307e02aeb58e110679c239fb1b73a4c4fc5bc043eb6cda31e309a78065ee087194d483afa3c1c249c22017a03e643
|
7
|
+
data.tar.gz: 6f17186c5a4a3ae9dce8b4866b3c87d4c94d5c65a829b28ade3f4aa76d464f572ca05fcc45da173516f0b4abf7376dd53873994ff06307bfa8e01b4f3c4b77e8
|
@@ -50,7 +50,14 @@ module Onebox
|
|
50
50
|
protected
|
51
51
|
|
52
52
|
def html_doc
|
53
|
-
@html_doc
|
53
|
+
return @html_doc if @html_doc
|
54
|
+
|
55
|
+
headers = nil
|
56
|
+
headers = { 'Cookie' => options[:cookie] } if options[:cookie]
|
57
|
+
|
58
|
+
response = (Onebox::Helpers.fetch_response(url, nil, nil, headers) rescue nil)
|
59
|
+
|
60
|
+
@html_doc = Nokogiri::HTML(response)
|
54
61
|
end
|
55
62
|
|
56
63
|
def get_oembed
|
data/lib/onebox/helpers.rb
CHANGED
@@ -39,8 +39,9 @@ module Onebox
|
|
39
39
|
og
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.fetch_response(location, limit=
|
42
|
+
def self.fetch_response(location, limit=nil, domain=nil, headers=nil)
|
43
43
|
|
44
|
+
limit ||= 5
|
44
45
|
limit = Onebox.options.redirect_limit if limit > Onebox.options.redirect_limit
|
45
46
|
|
46
47
|
raise Net::HTTPError.new('HTTP redirect too deep', location) if limit == 0
|
@@ -70,7 +71,7 @@ module Onebox
|
|
70
71
|
http.request(request) do |response|
|
71
72
|
|
72
73
|
if cookie = response.get_fields('set-cookie')
|
73
|
-
header = { '
|
74
|
+
header = { 'Cookie' => cookie.join }
|
74
75
|
end
|
75
76
|
|
76
77
|
header = nil unless header.is_a? Hash
|
data/lib/onebox/preview.rb
CHANGED
@@ -66,7 +66,11 @@ module Onebox
|
|
66
66
|
|
67
67
|
def engine
|
68
68
|
return nil unless @engine_class
|
69
|
-
@engine
|
69
|
+
return @engine if @engine
|
70
|
+
|
71
|
+
@engine = @engine_class.new(@url, cache)
|
72
|
+
@engine.options = @options
|
73
|
+
@engine
|
70
74
|
end
|
71
75
|
|
72
76
|
class InvalidURI < StandardError; end
|
data/lib/onebox/version.rb
CHANGED
@@ -83,6 +83,20 @@ describe Onebox::Engine::WhitelistedGenericOnebox do
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
+
describe "cookie support" do
|
87
|
+
let(:url) { "http://cookie-test.com" }
|
88
|
+
before do
|
89
|
+
fake(url, response('dailymail'))
|
90
|
+
end
|
91
|
+
|
92
|
+
it "sends the cookie with the request" do
|
93
|
+
onebox = described_class.new(url)
|
94
|
+
onebox.options = { cookie: "evil=trout" }
|
95
|
+
expect(onebox.to_html).not_to be_empty
|
96
|
+
expect(FakeWeb.last_request['Cookie']).to eq('evil=trout')
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
86
100
|
describe 'to_html' do
|
87
101
|
after(:each) do
|
88
102
|
Onebox.options = Onebox::DEFAULTS
|
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.
|
4
|
+
version: 1.8.11
|
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-06-
|
13
|
+
date: 2017-06-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|