open_uri_redirections 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -7
- data/lib/open-uri/redirections_patch.rb +7 -8
- data/lib/open_uri_redirections/version.rb +1 -1
- data/spec/redirections_spec.rb +7 -1
- data/spec/samples/http_safe2.response +9 -0
- data/spec/spec_helper.rb +2 -0
- metadata +53 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
1
|
+
---
|
2
|
+
SHA512:
|
3
|
+
metadata.gz: 3188333a58a356a9c6453a60c85883c795ba37cc892593b53dd4745d924ad1cd826cc71801feee15f9a6a76eff7474dbbeea9f9eb843936ec5625dd7c097caac
|
4
|
+
data.tar.gz: db5c9b8b959cc73bb0d9dd30c510d372362580dcf4204f3a6f85354b8c1a8a74e9812a6c759bf9ef4c2b7cc2999e57090bc8c0e379e67377e94fa0bf4df2ec91
|
5
|
+
SHA1:
|
6
|
+
metadata.gz: 98bd6a10771e7d458abebd244f18b8ea03a34199
|
7
|
+
data.tar.gz: c9b7c6ca9b4caef0449827d936b7688bc3fae1a1
|
@@ -17,12 +17,7 @@ module OpenURI
|
|
17
17
|
alias_method :redirectable_cautious?, :redirectable?
|
18
18
|
|
19
19
|
def redirectable?(uri1, uri2)
|
20
|
-
|
21
|
-
|
22
|
-
# clear to prevent leaking (e.g. to block)
|
23
|
-
Thread.current[:__open_uri_redirections__] = nil
|
24
|
-
|
25
|
-
case allow_redirections
|
20
|
+
case Thread.current[:__open_uri_redirections__]
|
26
21
|
when :safe
|
27
22
|
redirectable_safe? uri1, uri2
|
28
23
|
when :all
|
@@ -51,10 +46,14 @@ module OpenURI
|
|
51
46
|
allow_redirections = options.delete :allow_redirections if options
|
52
47
|
Thread.current[:__open_uri_redirections__] = allow_redirections
|
53
48
|
|
49
|
+
block2 = lambda { |io|
|
50
|
+
Thread.current[:__open_uri_redirections__] = nil
|
51
|
+
block[io]
|
52
|
+
}
|
53
|
+
|
54
54
|
begin
|
55
|
-
self.open_uri_original name, *rest, &block
|
55
|
+
self.open_uri_original name, *rest, &(block ? block2 : nil)
|
56
56
|
ensure
|
57
|
-
# clear (redirectable? might not be called due to an exception)
|
58
57
|
Thread.current[:__open_uri_redirections__] = nil
|
59
58
|
end
|
60
59
|
end
|
data/spec/redirections_spec.rb
CHANGED
@@ -41,6 +41,12 @@ describe "OpenURI" do
|
|
41
41
|
).to eq("Hello, this is Safe.")
|
42
42
|
end
|
43
43
|
|
44
|
+
it "should follow safe double redirections" do
|
45
|
+
expect(
|
46
|
+
open("http://safe2.com", :allow_redirections => :safe).read
|
47
|
+
).to eq("Hello, this is Safe.")
|
48
|
+
end
|
49
|
+
|
44
50
|
it "should follow safe redirections with block" do
|
45
51
|
expect { |b|
|
46
52
|
open("http://safe.com", :allow_redirections => :safe, &b)
|
@@ -107,7 +113,7 @@ describe "OpenURI" do
|
|
107
113
|
end
|
108
114
|
|
109
115
|
describe "threads" do
|
110
|
-
it "
|
116
|
+
it "seems to work (could be false positive)" do
|
111
117
|
allow(OpenURI).to receive(:open_uri_original) { |*a,&b| sleep rand; OpenURI.open_uri_original__ *a, &b }
|
112
118
|
ts = []
|
113
119
|
Thread.abort_on_exception = true
|
data/spec/spec_helper.rb
CHANGED
@@ -15,5 +15,7 @@ $samples_dir = File.dirname(__FILE__) + '/samples'
|
|
15
15
|
FakeWeb.register_uri(:get, "http://safe.com/", :response => open("#{$samples_dir}/http_safe.response").read)
|
16
16
|
FakeWeb.register_uri(:get, "https://safe.com/", :response => open("#{$samples_dir}/https_safe.response").read)
|
17
17
|
|
18
|
+
FakeWeb.register_uri(:get, "http://safe2.com/", :response => open("#{$samples_dir}/http_safe2.response").read)
|
19
|
+
|
18
20
|
FakeWeb.register_uri(:get, "https://unsafe.com/", :response => open("#{$samples_dir}/https_unsafe.response").read)
|
19
21
|
FakeWeb.register_uri(:get, "http://unsafe.com/", :response => open("#{$samples_dir}/http_unsafe.response").read)
|
metadata
CHANGED
@@ -1,68 +1,60 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: open_uri_redirections
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Jaime Iniesta
|
8
8
|
- Gabriel Cebrian
|
9
9
|
- Felix C. Stegerman
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
|
14
|
+
date: 2014-11-26 00:00:00 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
16
17
|
name: rspec
|
17
|
-
requirement: !ruby/object:Gem::Requirement
|
18
|
-
requirements:
|
19
|
-
- - "~>"
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 3.1.0
|
22
|
-
type: :development
|
23
18
|
prerelease: false
|
24
|
-
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
28
23
|
version: 3.1.0
|
29
|
-
- !ruby/object:Gem::Dependency
|
30
|
-
name: fakeweb
|
31
|
-
requirement: !ruby/object:Gem::Requirement
|
32
|
-
requirements:
|
33
|
-
- - "~>"
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: 1.3.0
|
36
24
|
type: :development
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: fakeweb
|
37
28
|
prerelease: false
|
38
|
-
|
39
|
-
requirements:
|
40
|
-
- -
|
41
|
-
- !ruby/object:Gem::Version
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
42
33
|
version: 1.3.0
|
43
|
-
- !ruby/object:Gem::Dependency
|
44
|
-
name: rake
|
45
|
-
requirement: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - "~>"
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: 10.3.2
|
50
34
|
type: :development
|
35
|
+
version_requirements: *id002
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
51
38
|
prerelease: false
|
52
|
-
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
39
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
56
43
|
version: 10.3.2
|
44
|
+
type: :development
|
45
|
+
version_requirements: *id003
|
57
46
|
description: OpenURI patch to allow redirections between HTTP and HTTPS
|
58
|
-
email:
|
47
|
+
email:
|
59
48
|
- jaimeiniesta@gmail.com
|
60
49
|
executables: []
|
50
|
+
|
61
51
|
extensions: []
|
52
|
+
|
62
53
|
extra_rdoc_files: []
|
63
|
-
|
64
|
-
|
65
|
-
-
|
54
|
+
|
55
|
+
files:
|
56
|
+
- .gitignore
|
57
|
+
- .travis.yml
|
66
58
|
- Gemfile
|
67
59
|
- LICENSE.txt
|
68
60
|
- README.md
|
@@ -73,37 +65,41 @@ files:
|
|
73
65
|
- open_uri_redirections.gemspec
|
74
66
|
- spec/redirections_spec.rb
|
75
67
|
- spec/samples/http_safe.response
|
68
|
+
- spec/samples/http_safe2.response
|
76
69
|
- spec/samples/http_unsafe.response
|
77
70
|
- spec/samples/https_safe.response
|
78
71
|
- spec/samples/https_unsafe.response
|
79
72
|
- spec/spec_helper.rb
|
80
73
|
homepage: https://github.com/jaimeiniesta/open_uri_redirections
|
81
|
-
licenses:
|
74
|
+
licenses:
|
82
75
|
- MIT
|
83
76
|
metadata: {}
|
77
|
+
|
84
78
|
post_install_message:
|
85
79
|
rdoc_options: []
|
86
|
-
|
80
|
+
|
81
|
+
require_paths:
|
87
82
|
- lib
|
88
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
-
requirements:
|
90
|
-
-
|
91
|
-
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
version: '0'
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- &id004
|
86
|
+
- ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: "0"
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- *id004
|
98
92
|
requirements: []
|
93
|
+
|
99
94
|
rubyforge_project:
|
100
|
-
rubygems_version: 2.
|
95
|
+
rubygems_version: 2.0.14
|
101
96
|
signing_key:
|
102
97
|
specification_version: 4
|
103
98
|
summary: OpenURI patch to allow redirections between HTTP and HTTPS
|
104
|
-
test_files:
|
99
|
+
test_files:
|
105
100
|
- spec/redirections_spec.rb
|
106
101
|
- spec/samples/http_safe.response
|
102
|
+
- spec/samples/http_safe2.response
|
107
103
|
- spec/samples/http_unsafe.response
|
108
104
|
- spec/samples/https_safe.response
|
109
105
|
- spec/samples/https_unsafe.response
|