ruby-openid 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ruby-openid might be problematic. Click here for more details.

@@ -238,15 +238,15 @@ module OpenID
238
238
 
239
239
  private
240
240
  def setup_encoding(response)
241
- return unless defined?(::Encoding::ASCII_8BIT)
242
- charset = response.type_params["charset"]
243
- return if charset.nil?
244
- encoding = nil
241
+ return unless defined?(Encoding.default_external)
242
+ return unless charset = response.type_params["charset"]
243
+
245
244
  begin
246
245
  encoding = Encoding.find(charset)
247
246
  rescue ArgumentError
248
247
  end
249
- encoding ||= Encoding::ASCII_8BIT
248
+ encoding ||= Encoding.default_external
249
+
250
250
  body = response.body
251
251
  if body.respond_to?(:force_encoding)
252
252
  body.force_encoding(encoding)
@@ -1,3 +1,3 @@
1
1
  module OpenID
2
- VERSION = "2.2.0"
3
- end
2
+ VERSION = "2.2.1"
3
+ end
@@ -126,7 +126,28 @@ EOHTML
126
126
  }
127
127
  end
128
128
 
129
+ def _unencoded_page
130
+ lambda { |req, resp|
131
+ resp['Content-Type'] = "text/html"
132
+ body = "unencoded-body"
133
+ body.force_encoding("ASCII-8BIT") if body.respond_to?(:force_encoding)
134
+ resp.body = body
135
+ }
136
+ end
137
+
138
+ def _badly_encoded_page
139
+ lambda { |req, resp|
140
+ resp['Content-Type'] = "text/html; charset=wtf"
141
+ body = "badly-encoded-body"
142
+ body.force_encoding("ASCII-8BIT") if body.respond_to?(:force_encoding)
143
+ resp.body = body
144
+ }
145
+ end
146
+
129
147
  def setup
148
+ if defined?(Encoding.default_external)
149
+ @encoding_was = Encoding.default_external
150
+ end
130
151
  @fetcher = OpenID::StandardFetcher.new
131
152
  @logfile = StringIO.new
132
153
  @weblog = WEBrick::Log.new(logfile=@logfile)
@@ -152,6 +173,8 @@ EOHTML
152
173
  @server.mount_proc('/post', _require_post)
153
174
  @server.mount_proc('/redirect_loop', _redirect_loop)
154
175
  @server.mount_proc('/utf8_page', _utf8_page)
176
+ @server.mount_proc('/unencoded_page', _unencoded_page)
177
+ @server.mount_proc('/badly_encoded_page', _badly_encoded_page)
155
178
  @server.start
156
179
  }
157
180
  @uri = _uri_build
@@ -168,6 +191,9 @@ EOHTML
168
191
  end
169
192
 
170
193
  def teardown
194
+ if defined?(Encoding.default_external)
195
+ Encoding.default_external = @encoding_was
196
+ end
171
197
  @server.shutdown
172
198
  # Sleep a little because sometimes this blocks forever.
173
199
  @server_thread.join
@@ -234,6 +260,30 @@ EOHTML
234
260
  end
235
261
  end
236
262
 
263
+ def test_unencoded_page
264
+ if defined?(Encoding.default_external)
265
+ Encoding.default_external = Encoding::SHIFT_JIS
266
+ end
267
+ uri = _uri_build('/unencoded_page')
268
+ response = @fetcher.fetch(uri)
269
+ assert_equal("unencoded-body", response.body)
270
+ if defined?(Encoding.default_external)
271
+ assert_equal(Encoding::US_ASCII, response.body.encoding)
272
+ end
273
+ end
274
+
275
+ def test_badly_encoded_page
276
+ if defined?(Encoding.default_external)
277
+ Encoding.default_external = Encoding::SHIFT_JIS
278
+ end
279
+ uri = _uri_build('/badly_encoded_page')
280
+ response = @fetcher.fetch(uri)
281
+ assert_equal("badly-encoded-body", response.body)
282
+ if defined?(Encoding.default_external)
283
+ assert_equal(Encoding::SHIFT_JIS, response.body.encoding)
284
+ end
285
+ end
286
+
237
287
  def test_cases
238
288
  for path, expected_code, expected_url in @@cases
239
289
  uri = _uri_build(path)
data/test/test_idres.rb CHANGED
@@ -63,7 +63,7 @@ module OpenID
63
63
  [["openid1", OPENID1_NS, OPENID1_FIELDS],
64
64
  ["openid1", OPENID11_NS, OPENID1_FIELDS],
65
65
  ["openid2", OPENID2_NS, OPENID2_FIELDS],
66
- ].each do |ver, ns, all_fields|
66
+ ].each_with_index do |(ver, ns, all_fields), i|
67
67
  all_fields.each do |field|
68
68
  test = lambda do
69
69
  fields = all_fields.dup
@@ -74,7 +74,7 @@ module OpenID
74
74
  idres.send(:check_for_fields)
75
75
  }
76
76
  end
77
- define_method("test_#{ver}_check_missing_#{field}", test)
77
+ define_method("test_#{i}_#{ver}_check_missing_#{field}", test)
78
78
  end
79
79
  end
80
80
  end
@@ -84,7 +84,7 @@ module OpenID
84
84
  [["openid1", OPENID1_NS, OPENID1_FIELDS, OPENID1_SIGNED],
85
85
  ["openid1", OPENID11_NS, OPENID1_FIELDS, OPENID1_SIGNED],
86
86
  ["openid2", OPENID2_NS, OPENID2_FIELDS, OPENID2_SIGNED],
87
- ].each do |ver, ns, all_fields, signed_fields|
87
+ ].each_with_index do |(ver, ns, all_fields, signed_fields), i|
88
88
  signed_fields.each do |signed_field|
89
89
  test = lambda do
90
90
  fields = signed_fields.dup
@@ -97,7 +97,7 @@ module OpenID
97
97
  idres.send(:check_for_fields)
98
98
  }
99
99
  end
100
- define_method("test_#{ver}_check_missing_signed_#{signed_field}", test)
100
+ define_method("test_#{i}_#{ver}_check_missing_signed_#{signed_field}", test)
101
101
  end
102
102
  end
103
103
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-openid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire: openid
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-07 00:00:00.000000000 Z
12
+ date: 2012-09-27 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: openid@janrain.com
@@ -218,7 +218,8 @@ files:
218
218
  - LICENSE
219
219
  - UPGRADE.md
220
220
  homepage: https://github.com/openid/ruby-openid
221
- licenses: []
221
+ licenses:
222
+ - Apache Software License
222
223
  post_install_message:
223
224
  rdoc_options:
224
225
  - --main
@@ -233,7 +234,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
233
234
  version: '0'
234
235
  segments:
235
236
  - 0
236
- hash: 3380124184653495316
237
+ hash: -2604511254745544054
237
238
  required_rubygems_version: !ruby/object:Gem::Requirement
238
239
  none: false
239
240
  requirements:
@@ -242,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
243
  version: '0'
243
244
  segments:
244
245
  - 0
245
- hash: 3380124184653495316
246
+ hash: -2604511254745544054
246
247
  requirements: []
247
248
  rubyforge_project:
248
249
  rubygems_version: 1.8.23