Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
188d5216
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
188d5216
编写于
1月 08, 2010
作者:
D
David Heinemeier Hansson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed that much of DateHelper wouldn't return html_safe? strings [DHH]
上级
5ea13094
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
5 deletion
+29
-5
actionpack/CHANGELOG
actionpack/CHANGELOG
+2
-0
actionpack/lib/action_view/helpers/date_helper.rb
actionpack/lib/action_view/helpers/date_helper.rb
+5
-5
actionpack/test/template/date_helper_test.rb
actionpack/test/template/date_helper_test.rb
+22
-0
未找到文件。
actionpack/CHANGELOG
浏览文件 @
188d5216
*
Edge
*
*
Fixed
that
much
of
DateHelper
wouldn
't return html_safe? strings [DHH]
* Fixed that fragment caching should return a cache hit as html_safe (or it would all just get escaped) [DHH]
* Added that ActionController::Base now does helper :all instead of relying on the default ApplicationController in Rails to do it [DHH]
...
...
actionpack/lib/action_view/helpers/date_helper.rb
浏览文件 @
188d5216
...
...
@@ -616,7 +616,7 @@ def select_datetime
build_selects_from_types
(
order
)
else
"
#{
select_date
}#{
@options
[
:datetime_separator
]
}#{
select_time
}
"
"
#{
select_date
}#{
@options
[
:datetime_separator
]
}#{
select_time
}
"
.
html_safe!
end
end
...
...
@@ -835,7 +835,7 @@ def build_select(type, select_options_as_html)
select_html
<<
prompt_option_tag
(
type
,
@options
[
:prompt
])
+
"
\n
"
if
@options
[
:prompt
]
select_html
<<
select_options_as_html
.
to_s
content_tag
(
:select
,
select_html
,
select_options
)
+
"
\n
"
(
content_tag
(
:select
,
select_html
,
select_options
)
+
"
\n
"
).
html_safe!
end
# Builds a prompt option tag with supplied options or from default options
...
...
@@ -860,12 +860,12 @@ def prompt_option_tag(type, options)
# build_hidden(:year, 2008)
# => "<input id="post_written_on_1i" name="post[written_on(1i)]" type="hidden" value="2008" />"
def
build_hidden
(
type
,
value
)
tag
(
:input
,
{
(
tag
(
:input
,
{
:type
=>
"hidden"
,
:id
=>
input_id_from_type
(
type
),
:name
=>
input_name_from_type
(
type
),
:value
=>
value
})
+
"
\n
"
})
+
"
\n
"
).
html_safe!
end
# Returns the name attribute for the input tag
...
...
@@ -896,7 +896,7 @@ def build_selects_from_types(order)
separator
=
separator
(
type
)
unless
type
==
order
.
first
# don't add on last field
select
.
insert
(
0
,
separator
.
to_s
+
send
(
"select_
#{
type
}
"
).
to_s
)
end
select
select
.
html_safe!
end
# Returns the separator for a given datetime component
...
...
actionpack/test/template/date_helper_test.rb
浏览文件 @
188d5216
...
...
@@ -2475,6 +2475,28 @@ def test_select_time_should_not_change_passed_options_hash
},
options
)
end
def
test_select_html_safety
assert
select_day
(
16
).
html_safe?
assert
select_month
(
8
).
html_safe?
assert
select_year
(
Time
.
mktime
(
2003
,
8
,
16
,
8
,
4
,
18
)).
html_safe?
assert
select_minute
(
Time
.
mktime
(
2003
,
8
,
16
,
8
,
4
,
18
)).
html_safe?
assert
select_second
(
Time
.
mktime
(
2003
,
8
,
16
,
8
,
4
,
18
)).
html_safe?
assert
select_minute
(
8
,
:use_hidden
=>
true
).
html_safe?
assert
select_month
(
8
,
:prompt
=>
'Choose month'
).
html_safe?
assert
select_time
(
Time
.
mktime
(
2003
,
8
,
16
,
8
,
4
,
18
),
{},
:class
=>
'selector'
).
html_safe?
assert
select_date
(
Time
.
mktime
(
2003
,
8
,
16
),
:date_separator
=>
" / "
,
:start_year
=>
2003
,
:end_year
=>
2005
,
:prefix
=>
"date[first]"
).
html_safe?
end
def
test_object_select_html_safety
@post
=
Post
.
new
@post
.
written_on
=
Date
.
new
(
2004
,
6
,
15
)
assert
date_select
(
"post"
,
"written_on"
,
:default
=>
Time
.
local
(
2006
,
9
,
19
,
15
,
16
,
35
),
:include_blank
=>
true
).
html_safe?
assert
time_select
(
"post"
,
"written_on"
,
:ignore_date
=>
true
).
html_safe?
end
protected
def
with_env_tz
(
new_tz
=
'US/Eastern'
)
old_tz
,
ENV
[
'TZ'
]
=
ENV
[
'TZ'
],
new_tz
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录