Close
Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

PIVOTAL LABS
Standup 5/14/12 – Watch your SafeBuffer

Interesting Things

ActiveSupport::SafeBuffer do not work with all the features of #gsub. Mind your strings, or fix this bug in ruby!

# normal:
1.9.3-p125 :004 > "foo".gsub(/(?<my_string>.*)/) { $~[:my_string]*2 }
 => "foofoo"

# broken:
1.9.3-p125 :005 > "foo".html_safe.gsub(/(?<my_string>.*)/) { $~[:my_string]*2 }
 => ""

# round trip, back to working
1.9.3-p125 :006 > "foo".html_safe.to_str.gsub(/(?<my_string>.*)/) { $~[:my_string]*2 }
 => "foofoo"
</my_string></my_string></my_string>

Comments
  1. Trevor Turk says:

    I ran into this a few weeks ago — what a pain.

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *