Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
5f94b932
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,发现更多精彩内容 >>
提交
5f94b932
编写于
8月 16, 2011
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Properly escape glob characters.
上级
bfc43257
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
3 deletion
+27
-3
actionpack/lib/action_view/template/resolver.rb
actionpack/lib/action_view/template/resolver.rb
+12
-3
actionpack/test/controller/render_test.rb
actionpack/test/controller/render_test.rb
+14
-0
actionpack/test/fixtures/test/hello_w*rld.erb
actionpack/test/fixtures/test/hello_w*rld.erb
+1
-0
未找到文件。
actionpack/lib/action_view/template/resolver.rb
浏览文件 @
5f94b932
...
...
@@ -142,8 +142,12 @@ def query(path, details, formats)
# Helper for building query glob string based on resolver's pattern.
def
build_query
(
path
,
details
)
query
=
@pattern
.
dup
query
.
gsub!
(
/\:prefix(\/)?/
,
path
.
prefix
.
empty?
?
""
:
"
#{
path
.
prefix
}
\\
1"
)
# prefix can be empty...
query
.
gsub!
(
/\:action/
,
path
.
partial?
?
"_
#{
path
.
name
}
"
:
path
.
name
)
prefix
=
path
.
prefix
.
empty?
?
""
:
"
#{
escape_entry
(
path
.
prefix
)
}
\\
1"
query
.
gsub!
(
/\:prefix(\/)?/
,
prefix
)
partial
=
escape_entry
(
path
.
partial?
?
"_
#{
path
.
name
}
"
:
path
.
name
)
query
.
gsub!
(
/\:action/
,
partial
)
details
.
each
do
|
ext
,
variants
|
query
.
gsub!
(
/\:
#{
ext
}
/
,
"{
#{
variants
.
compact
.
uniq
.
join
(
','
)
}
}"
)
...
...
@@ -152,6 +156,10 @@ def build_query(path, details)
File
.
expand_path
(
query
,
@path
)
end
def
escape_entry
(
entry
)
entry
.
gsub
(
/(\*|\[|\]|\{|\}|\?)/
,
"
\\\\\\
1"
)
end
# Returns the file mtime from the filesystem.
def
mtime
(
p
)
File
.
mtime
(
p
)
...
...
@@ -228,8 +236,9 @@ def eql?(resolver)
class
OptimizedFileSystemResolver
<
FileSystemResolver
#:nodoc:
def
build_query
(
path
,
details
)
exts
=
EXTENSIONS
.
map
{
|
ext
|
details
[
ext
]
}
query
=
escape_entry
(
File
.
join
(
@path
,
path
))
File
.
join
(
@path
,
path
)
+
exts
.
map
{
|
ext
|
query
+
exts
.
map
{
|
ext
|
"{
#{
ext
.
compact
.
uniq
.
map
{
|
e
|
".
#{
e
}
,"
}
.join}}"
}.
join
end
...
...
actionpack/test/controller/render_test.rb
浏览文件 @
5f94b932
...
...
@@ -405,6 +405,14 @@ def render_with_explicit_template
render
:template
=>
"test/hello_world"
end
def
render_with_explicit_unescaped_template
render
:template
=>
"test/h*llo_world"
end
def
render_with_explicit_escaped_template
render
:template
=>
"test/hello_w*rld"
end
def
render_with_explicit_string_template
render
"test/hello_world"
end
...
...
@@ -1057,6 +1065,12 @@ def test_render_with_explicit_template
assert_response
:success
end
def
test_render_with_explicit_unescaped_template
assert_raise
(
ActionView
::
MissingTemplate
)
{
get
:render_with_explicit_unescaped_template
}
get
:render_with_explicit_escaped_template
assert_equal
"Hello w*rld!"
,
@response
.
body
end
def
test_render_with_explicit_string_template
get
:render_with_explicit_string_template
assert_equal
"<html>Hello world!</html>"
,
@response
.
body
...
...
actionpack/test/fixtures/test/hello_w*rld.erb
0 → 100644
浏览文件 @
5f94b932
Hello w*rld!
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录