Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add back broken charset support. Make charset_from_content_type an al…

…ias for charset.
  • Loading branch information...
commit ed98c1de8355f2e58929273e79011e1273567c17 1 parent e750fb4
@knu knu authored
Showing with 8 additions and 10 deletions.
  1. +8 −10 lib/mechanize/page.rb
View
18 lib/mechanize/page.rb
@@ -364,10 +364,14 @@ def labels_hash
return @labels_hash
end
- def self.charset content_type
- charset = content_type[/;\s*charset\s*=\s*([^()<>@,;:\\\"\/\[\]?={}\s]+)/i, 1]
- return nil if charset == 'none'
- charset
+ class << self
+ def charset content_type
+ charset = content_type[/;(?:\s*,)?\s*charset\s*=\s*([^()<>@,;:\\\"\/\[\]?={}\s]+)/i, 1]
+ return nil if charset == 'none'
+ charset
+ end
+
+ alias charset_from_content_type charset
end
def self.response_header_charset response
@@ -422,12 +426,6 @@ def html_body
''
end
end
-
- def self.charset_from_content_type content_type
- charset = content_type[/charset=([^; ]+)/i, 1]
- return nil if charset == 'none'
- charset
- end
end
require 'mechanize/headers'
Please sign in to comment.
Something went wrong with that request. Please try again.