Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ruby 1.9 and utf8 erb templates

#1881

First patch:


irb(main):001:0> require 'erb'
=> true
irb(main):002:0> puts ERB.new('test').src
#coding:UTF-8
_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.

Reported by Eugene Pimenov · February 5th, 2009 @ 04:39 AM

State: committed
Milestone: 2.x
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: none

Activity

  1. Eugene Pimenov
  2. DHH
    DHH
    • Assigned user set to Jeremy Kemper

    February 6th, 2009 @ 01:44 PM

  3. Repository
    Repository
    • State changed from new to committed

    (from [ae36fcedce1ffcf4f3331b444ea1779987c6615a]) Ruby 1.9 compat: call bytesize for content_length

    [#1881 ruby 1.9 and utf8 erb templates state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net http://github.com/rails/rails/co...

    February 6th, 2009 @ 07:04 PM

  4. Repository
    Repository

    (from [b1c1e3deb7d752292abaff34ba66a3eae030d252]) Ruby 1.9 compat: change encoding of action_view/renderable to utf-8, so erb templates can use utf-8 properly

    [#1881 ruby 1.9 and utf8 erb templates state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net http://github.com/rails/rails/co...

    February 6th, 2009 @ 07:04 PM