Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit d3dca2f

Browse files
author
Zaid Zawaideh
committed
fixed issue with jruby in 1.9 mode not handling string encoding from binary properly. Now falling back to using ASCII as source
1 parent b1d0c38 commit d3dca2f

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/openid/consumer/html_parse.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ def OpenID.unescape_hash(h)
3636
def OpenID.parse_link_attrs(html)
3737
begin
3838
stripped = html.gsub(REMOVED_RE,'')
39-
rescue ArgumentError, Encoding::UndefinedConversionError
40-
stripped = html.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '').gsub(REMOVED_RE,'')
39+
rescue ArgumentError
40+
begin
41+
stripped = html.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '').gsub(REMOVED_RE,'')
42+
rescue Encoding::UndefinedConversionError #needed for a problem in JRuby where it can't handle the conversion
43+
stripped = html.encode('UTF-8', 'ASCII', :invalid => :replace, :undef => :replace, :replace => '').gsub(REMOVED_RE,'')
44+
end
4145
end
4246
parser = HTMLTokenizer.new(stripped)
4347

0 commit comments

Comments
 (0)