open_uri_redirections 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b8def15fe94729d1d4b1c78fa4852a0990860598
4
+ data.tar.gz: 822897ed3d8b22f28b3155a2ab09ef6f8986ef86
5
+ SHA512:
6
+ metadata.gz: 1a04fd1cd49c2109376c758d0300f806dfb3e1d15292a29020aa0637ca542a507e3c634cff2d646f28d22771cb2a159fa1e27b1539a262f5988de2142970b134
7
+ data.tar.gz: afb121dc1b104a956f4daba3ccfd89ef5271f4405bd9d5f862dc3d77909d1a8bf0c16b347f71ad05d7c4ac19a934d59f2591d4c82ea3f75137d7848d0c6aac1c
data/.gitignore CHANGED
@@ -4,6 +4,8 @@
4
4
  .config
5
5
  .yardoc
6
6
  .rvmrc
7
+ .ruby-gemset
8
+ .ruby-version
7
9
  Gemfile.lock
8
10
  InstalledFiles
9
11
  _yardoc
@@ -1,4 +1,5 @@
1
1
  rvm:
2
2
  - 1.8.7
3
3
  - 1.9.2
4
- - 1.9.3
4
+ - 1.9.3
5
+ - 2.0.0
@@ -29,27 +29,29 @@ module OpenURI
29
29
  #
30
30
  # The original open_uri takes *args but then doesn't do anything with them.
31
31
  # Assume we can only handle a hash.
32
- def self.open_uri(name, options = {}, &block)
33
- allow_redirections = options.delete :allow_redirections
32
+ def self.open_uri(name, *rest, &block)
33
+ mode, _, rest = OpenURI.scan_open_optional_arguments(*rest)
34
+ options = rest.first if !rest.empty? && Hash === rest.first
34
35
 
36
+ allow_redirections = options.delete :allow_redirections if options
35
37
  case allow_redirections
36
38
  when :safe
37
- class <<self
39
+ class << self
38
40
  remove_method :redirectable?
39
41
  alias_method :redirectable?, :redirectable_safe?
40
42
  end
41
43
  when :all
42
- class <<self
44
+ class << self
43
45
  remove_method :redirectable?
44
46
  alias_method :redirectable?, :redirectable_all?
45
47
  end
46
48
  else
47
- class <<self
49
+ class << self
48
50
  remove_method :redirectable?
49
51
  alias_method :redirectable?, :redirectable_cautious?
50
52
  end
51
53
  end
52
54
 
53
- self.open_uri_original name, options, &block
55
+ self.open_uri_original name, *rest, &block
54
56
  end
55
- end
57
+ end
@@ -1,3 +1,3 @@
1
1
  module OpenUriRedirections
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -75,5 +75,19 @@ describe "OpenURI" do
75
75
  }.to yield_control
76
76
  end
77
77
  end
78
+
79
+ describe "with mode argument" do
80
+ it "should disallow HTTP => HTTPS redirections" do
81
+ expect {
82
+ open("http://safe.com", 'r')
83
+ }.to raise_error(RuntimeError, "redirection forbidden: http://safe.com -> https://safe.com/")
84
+ end
85
+
86
+ it "should allow HTTP => HTTPS redirections" do
87
+ expect {
88
+ open("http://safe.com", 'r', :allow_redirections => :safe)
89
+ }.to_not raise_error
90
+ end
91
+ end
78
92
  end
79
93
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_uri_redirections
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 0.1.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jaime Iniesta
@@ -10,12 +9,11 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-03-11 00:00:00.000000000 Z
12
+ date: 2013-11-18 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rspec
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
18
  - - ~>
21
19
  - !ruby/object:Gem::Version
@@ -23,7 +21,6 @@ dependencies:
23
21
  type: :development
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
25
  - - ~>
29
26
  - !ruby/object:Gem::Version
@@ -31,7 +28,6 @@ dependencies:
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: fakeweb
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
32
  - - ~>
37
33
  - !ruby/object:Gem::Version
@@ -39,7 +35,6 @@ dependencies:
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
39
  - - ~>
45
40
  - !ruby/object:Gem::Version
@@ -47,7 +42,6 @@ dependencies:
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: rake
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
46
  - - ~>
53
47
  - !ruby/object:Gem::Version
@@ -55,7 +49,6 @@ dependencies:
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
53
  - - ~>
61
54
  - !ruby/object:Gem::Version
@@ -85,33 +78,26 @@ files:
85
78
  - spec/spec_helper.rb
86
79
  homepage: https://github.com/jaimeiniesta/open_uri_redirections
87
80
  licenses: []
81
+ metadata: {}
88
82
  post_install_message:
89
83
  rdoc_options: []
90
84
  require_paths:
91
85
  - lib
92
86
  required_ruby_version: !ruby/object:Gem::Requirement
93
- none: false
94
87
  requirements:
95
- - - ! '>='
88
+ - - '>='
96
89
  - !ruby/object:Gem::Version
97
90
  version: '0'
98
- segments:
99
- - 0
100
- hash: 2413654041070005087
101
91
  required_rubygems_version: !ruby/object:Gem::Requirement
102
- none: false
103
92
  requirements:
104
- - - ! '>='
93
+ - - '>='
105
94
  - !ruby/object:Gem::Version
106
95
  version: '0'
107
- segments:
108
- - 0
109
- hash: 2413654041070005087
110
96
  requirements: []
111
97
  rubyforge_project:
112
- rubygems_version: 1.8.25
98
+ rubygems_version: 2.0.6
113
99
  signing_key:
114
- specification_version: 3
100
+ specification_version: 4
115
101
  summary: OpenURI patch to allow redirections between HTTP and HTTPS
116
102
  test_files:
117
103
  - spec/redirections_spec.rb