Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix issue with Nokogiri caused by libxml2 regarding encoding getting …

  • Loading branch information...
commit 04cb500c8107adfefb099e1b6b3d721dd3b133d6 1 parent 8e9e3af
@darkhelmet authored
Showing with 17 additions and 3 deletions.
  1. +1 −0  .rvmrc
  2. +3 −2 lib/rack/gist.rb
  3. +13 −1 spec/rack-gist_spec.rb
View
1  .rvmrc
@@ -0,0 +1 @@
+rvm use ree@rack-gist
View
5 lib/rack/gist.rb
@@ -8,7 +8,8 @@ def initialize(app, options = {})
@options = {
:jquery => true,
:cache_time => 3600,
- :http_cache_time => 3600
+ :http_cache_time => 3600,
+ :encoding => 'utf-8'
}.merge(options)
end
@@ -35,7 +36,7 @@ def rewrite(status, headers, body)
node.add_child(jquery_helper)
end
end
- end.to_s
+ end.to_html(:encoding => @options[:encoding])
body = [body]
headers['Content-Length'] = body.map { |part| Rack::Utils.bytesize(part) }.inject(0) { |sum, size| sum + size }.to_s
end
View
14 spec/rack-gist_spec.rb
@@ -119,7 +119,7 @@ def middleware(options = {}, headers = { 'Content-Type' => 'text/html' })
status, headers, body = a.call(mock_env)
status.should == 200
headers['Content-Type'].should == 'text/html'
- headers['Content-Length'].should == '1069'
+ headers['Content-Length'].should == '1066'
end
end
@@ -205,4 +205,16 @@ def middleware(options = {}, headers = { 'Content-Type' => 'text/html' })
headers['Cache-Control'].should be_nil
end
end
+
+ it 'should encode to the correct content type' do
+ middleware.tap do |a|
+ status, headers, body = a.call(mock_env)
+ pbody(body).should match('utf-8')
+ end
+
+ middleware(:encoding => 'US-ASCII').tap do |a|
+ status, headers, body = a.call(mock_env)
+ pbody(body).should match('US-ASCII')
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.