为什么 Rails 2.3.16 在表单字段中转义引号字符? [英] Why does Rails 2.3.16 escape quote chars in form fields?

查看:25
本文介绍了为什么 Rails 2.3.16 在表单字段中转义引号字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑一个简单的对象 Shop,它有一个字符串属性 'name'.

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

我们的示例商店名称为:

Our example shop has the name:

Sam's Diner & Cafe - "deelicious"

如果我们的观点有

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

Rails 2.3.15 将为文本字段生成

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;" />

在浏览器(Chrome、Firefox)屏幕上的表单文本字段中显示为

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

Sam's Diner & Cafe - "deelicious"

Rails 2.3.16 将生成

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;" />

在浏览器(Chrome、Firefox)屏幕上的表单文本字段中显示为

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...

这是由现在转义撇号的更改引起的https://github.com/rails/rails/commit/d549df7133f2b0903217chttps://github.com/rails/rails/compare/v2.3.15...v2.3.16#L20L22

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?

此问题已在 Rails 2.3.17 中解决

This issue was resolved in Rails 2.3.17

推荐答案

这似乎在 2.3.16 中被破坏了.请参阅 https://github.com/rails/rails/issues/9108 以获取修复至少对我有用.

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.

这篇关于为什么 Rails 2.3.16 在表单字段中转义引号字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆