Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
社会瑞弟呀
brakeman
提交
3498a29d
B
brakeman
项目概览
社会瑞弟呀
/
brakeman
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
brakeman
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
3498a29d
编写于
4月 06, 2012
作者:
J
Justin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #71 from presidentbeef/handle_layout_in_views
Treat render :layout in views like partials
上级
26c6ecb2
8b3714e2
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
35 addition
and
11 deletion
+35
-11
lib/brakeman/processors/base_processor.rb
lib/brakeman/processors/base_processor.rb
+21
-6
lib/brakeman/processors/erb_template_processor.rb
lib/brakeman/processors/erb_template_processor.rb
+1
-1
lib/brakeman/processors/erubis_template_processor.rb
lib/brakeman/processors/erubis_template_processor.rb
+1
-1
lib/brakeman/processors/haml_template_processor.rb
lib/brakeman/processors/haml_template_processor.rb
+1
-1
lib/brakeman/processors/lib/render_helper.rb
lib/brakeman/processors/lib/render_helper.rb
+7
-2
test/apps/rails3.1/app/views/users/_test_layout.html.erb
test/apps/rails3.1/app/views/users/_test_layout.html.erb
+1
-0
test/apps/rails3.1/app/views/users/index.html.erb
test/apps/rails3.1/app/views/users/index.html.erb
+3
-0
未找到文件。
lib/brakeman/processors/base_processor.rb
浏览文件 @
3498a29d
...
...
@@ -202,9 +202,14 @@ class Brakeman::BaseProcessor < SexpProcessor
exp
end
#Convenience method for `make_render exp, true`
def
make_render_in_view
exp
make_render
exp
,
true
end
#Generates :render node from call to render.
def
make_render
exp
render_type
,
value
,
rest
=
find_render_type
exp
[
3
]
def
make_render
exp
,
in_view
=
false
render_type
,
value
,
rest
=
find_render_type
exp
[
3
]
,
in_view
rest
=
process
rest
result
=
Sexp
.
new
(
:render
,
render_type
,
value
,
rest
)
result
.
line
(
exp
.
line
)
...
...
@@ -214,9 +219,11 @@ class Brakeman::BaseProcessor < SexpProcessor
#Determines the type of a call to render.
#
#Possible types are:
#:action, :default :file, :inline, :js, :json, :nothing, :partial,
#:action, :default
,
:file, :inline, :js, :json, :nothing, :partial,
#:template, :text, :update, :xml
def
find_render_type
args
#
#And also :layout for inside templates
def
find_render_type
args
,
in_view
=
false
rest
=
Sexp
.
new
(
:hash
)
type
=
nil
value
=
nil
...
...
@@ -244,10 +251,18 @@ class Brakeman::BaseProcessor < SexpProcessor
value
=
args
[
1
]
end
types_in_hash
=
Set
[
:action
,
:file
,
:inline
,
:js
,
:json
,
:nothing
,
:partial
,
:text
,
:update
,
:xml
]
#render :layout => "blah" means something else when in a template
if
in_view
types_in_hash
<<
:layout
end
#Look for "type" of render in options hash
#For example, render :file => "blah"
if
hash
?
args
[
-
1
]
hash_iterate
(
args
[
-
1
])
do
|
key
,
val
|
case
key
[
1
]
when
:action
,
:file
,
:inline
,
:js
,
:json
,
:nothing
,
:partial
,
:text
,
:update
,
:
xml
if
types_in_hash
.
include?
key
[
1
]
type
=
key
[
1
]
value
=
val
else
...
...
lib/brakeman/processors/erb_template_processor.rb
浏览文件 @
3498a29d
...
...
@@ -44,7 +44,7 @@ class Brakeman::ErbTemplateProcessor < Brakeman::TemplateProcessor
end
elsif
target
==
nil
and
method
==
:render
exp
[
3
]
=
process
(
exp
[
3
])
make_render
exp
make_render
_in_view
exp
else
args
=
exp
[
3
]
=
process
(
exp
[
3
])
call
=
Sexp
.
new
:call
,
target
,
method
,
args
...
...
lib/brakeman/processors/erubis_template_processor.rb
浏览文件 @
3498a29d
...
...
@@ -41,7 +41,7 @@ class Brakeman::ErubisTemplateProcessor < Brakeman::TemplateProcessor
end
elsif
target
==
nil
and
method
==
:render
exp
[
3
]
=
process
exp
[
3
]
make_render
exp
make_render
_in_view
exp
else
args
=
exp
[
3
]
=
process
(
exp
[
3
])
call
=
Sexp
.
new
:call
,
target
,
method
,
args
...
...
lib/brakeman/processors/haml_template_processor.rb
浏览文件 @
3498a29d
...
...
@@ -92,7 +92,7 @@ class Brakeman::HamlTemplateProcessor < Brakeman::TemplateProcessor
elsif
target
==
nil
and
method
==
:render
#Process call to render()
exp
[
3
]
=
process
exp
[
3
]
make_render
exp
make_render
_in_view
exp
else
args
=
process
exp
[
3
]
call
=
Sexp
.
new
:call
,
target
,
method
,
args
...
...
lib/brakeman/processors/lib/render_helper.rb
浏览文件 @
3498a29d
...
...
@@ -11,8 +11,13 @@ module Brakeman::RenderHelper
when
:action
process_action
exp
[
2
][
1
],
exp
[
3
]
when
:default
process_template
template_name
,
exp
[
3
]
when
:partial
begin
process_template
template_name
,
exp
[
3
]
rescue
ArgumentError
=>
e
Brakeman
.
debug
"Problem processing render:
#{
exp
}
"
raise
e
end
when
:partial
,
:layout
process_partial
exp
[
2
],
exp
[
3
]
when
:nothing
end
...
...
test/apps/rails3.1/app/views/users/_test_layout.html.erb
0 → 100644
浏览文件 @
3498a29d
<%=
raw
@something
%>
test/apps/rails3.1/app/views/users/index.html.erb
浏览文件 @
3498a29d
...
...
@@ -29,3 +29,6 @@
<br
/>
<%=
link_to
'New User'
,
new_user_path
%>
<%=
@something
=
params
[
"something_bad"
]
%>
<%=
render
:layout
=>
"test_layout"
%>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录