s01ipsist
s01ipsist

Reputation: 3137

Why does Rails 2.3.16 escape quote chars in form fields?

Consider a simple object Shop which has a string attribute 'name'.

Our example shop has the name:

Sam's Diner & Cafe - "deelicious"

If our view has

<% form_for(@shop) do |f| %>
<%= f.text_field :name %>
<% end -%>

Rails 2.3.15 will generate for the text field

<input id="shop_name" name="shop[name]" type="text" value="Sam's Diner &amp; Cafe - &quot;deelicious&quot;" />

which displays in the browser (Chrome, Firefox) on screen in the form text field as

Sam's Diner & Cafe - "deelicious"

Rails 2.3.16 will generate

<input id="shop_name" name="shop[name]" type="text" value="Sam&amp;#x27;s Diner &amp; Cafe - &quot;deelicious&quot;" />

which displays in the browser (Chrome, Firefox) on screen in the form text field as

Sam&amp;#x27;s Diner & Cafe - "deelicious"

which is undesirable behavior in a text field for me...

It's caused by this change which now escapes apostrophes https://github.com/rails/rails/commit/d549df7133f2b0bad8112890d478c33e990e12bc https://github.com/rails/rails/compare/v2.3.15...v2.3.16#L20L22

I guess my question is: is this a rails issue? if not, where is the problem?


Edit: This issue was resolved in Rails 2.3.17

Upvotes: 1

Views: 808

Answers (1)

Jeremy Strouse
Jeremy Strouse

Reputation: 44

This appears to have been something broken in 2.3.16. See https://github.com/rails/rails/issues/9108 for a fix that worked for me at least.

Upvotes: 2

Related Questions