Patches: Browse | Submit New | Admin

[#25530] Rails "render :inline" fails with erubis v2.6.4

Date:
2009-04-17 20:33
Priority:
3
Submitted By:
Nobody
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
Rails "render :inline" fails with erubis v2.6.4

Detailed description
Steps to reproduce:

# SomeController.rb

  def foo
    str = render_to_string :inline => "Some text with a single quote  '  in it."
    render :text => str
  end

# config/environment.rb

# Enable fast erubis
require 'erubis/helpers/rails_helper'
Erubis::Helpers::RailsHelper.engine_class = Erubis::FastEruby

The first request to the foo action will fail with the exception "nil is not a symbol"

This caused by a hash lookup failure caused by the InterpolationEnhancer modifying a string source that was passed to
it. The patch addresses this issue.

Hope this helps.

~Rohith

Add A Comment: Notepad

Please login


Followup

Message
Date: 2009-04-17 20:39
Sender: Rohith Ravi

diff -ur erubis-2.6.4/lib/erubis/enhancer.rb
erubis-2.6.4.modified/lib/erubis/enhancer.rb
--- erubis-2.6.4/lib/erubis/enhancer.rb	2009-04-17 13:11:49.000000000
-0700
+++ erubis-2.6.4.modified/lib/erubis/enhancer.rb	2009-04-17
13:10:14.000000000 -0700
@@ -663,8 +663,7 @@
 
     def _add_text_to_str(str, text)
       return if !text || text.empty?
-      text.gsub!(/['\#\\]/, '\\\\\&')
-      str << text
+      str << text.gsub(/['\#\\]/, '\\\\\&')
     end
 
     def add_expr_escaped(str, code)
Date: 2009-04-17 20:38
Sender: Rohith Ravi

Forgot to mention I was using Rails v2.1.0

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item