Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge commit 'f7b22deaf3ad03ebb2135ec6a4e57d66997f1081' into charset

* commit 'f7b22deaf3ad03ebb2135ec6a4e57d66997f1081':
  Properly find encoding with a trailing semicolon.

Conflicts:
	lib/www/mechanize/page.rb
  • Loading branch information...
commit 0410cef2fc11cd813cd1891bc728bf849553061d 2 parents b9b6336 + f7b22de
@tenderlove tenderlove authored
Showing with 6 additions and 1 deletion.
  1. +1 −1  lib/mechanize/page.rb
  2. +5 −0 test/test_page.rb
View
2  lib/mechanize/page.rb
@@ -29,7 +29,7 @@ def initialize(uri=nil, response=nil, body=nil, code=nil, mech=nil)
method = response.respond_to?(:each_header) ? :each_header : :each
response.send(method) do |header,v|
next unless v =~ /charset/i
- encoding = v.split('=').last.strip
+ encoding = v[/charset=([^; ]+)/, 1]
@encoding = encoding unless encoding == 'none'
end
View
5 test/test_page.rb
@@ -63,6 +63,11 @@ def test_page_gets_charset_sent_by_server
assert_equal 'UTF-8', page.encoding
end
+ def test_page_gets_charset_sent_by_server_with_trailing_semicolon
+ page = @agent.get("http://localhost/http_headers?content-type=#{CGI.escape('text/html; charset=UTF-8;')}")
+ assert_equal 'UTF-8', page.encoding
+ end
+
def test_set_encoding
page = @agent.get("http://localhost/file_upload.html")
page.encoding = 'UTF-8'
Please sign in to comment.
Something went wrong with that request. Please try again.