This project is archived and is in readonly mode.

#1881 ✓committed
Eugene Pimenov

ruby 1.9 and utf8 erb templates

Reported by Eugene Pimenov | February 5th, 2009 @ 04:39 AM | in 2.x

First patch:

irb(main):001:0> require 'erb'
=> true
irb(main):002:0> puts'test').src
_erbout = ''; _erbout.concat "test"; _erbout.force_encoding(__ENCODING__)
=> nil

it forces encoding to ENCODING. ENCODING equals encoding of ruby file that executes that code. And in Rails this code is executed by actionpack/lib/action_view/renderable.rb.

Second patch:

-          headers["Content-Length"] = body.size.to_s
+          headers["Content-Length"] = (body.respond_to?(:bytesize) ? body.bytesize : body.size).to_s

Content-length needs size in bytes, not in chars, so for 1.9 .size no longer valid.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

Referenced by