Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
55ae903c
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,发现更多精彩内容 >>
提交
55ae903c
编写于
2月 21, 2010
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Store compiled parameter filters so we don't have to compile them in each request.
上级
87a011df
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
40 addition
and
25 deletion
+40
-25
actionpack/lib/action_dispatch/http/filter_parameters.rb
actionpack/lib/action_dispatch/http/filter_parameters.rb
+40
-25
未找到文件。
actionpack/lib/action_dispatch/http/filter_parameters.rb
浏览文件 @
55ae903c
...
...
@@ -25,9 +25,16 @@ module Http
module
FilterParameters
extend
ActiveSupport
::
Concern
mattr_reader
:compiled_parameter_filter_for
@@compiled_parameter_filter_for
=
{}
# Return a hash of parameters with all sensitive data replaced.
def
filtered_parameters
@filtered_parameters
||=
process_parameter_filter
(
parameters
)
@filtered_parameters
||=
if
filtering_parameters?
process_parameter_filter
(
parameters
)
else
parameters
.
dup
end
end
alias
:fitered_params
:filtered_parameters
...
...
@@ -46,10 +53,18 @@ def filtered_env
protected
def
compile_parameter_filter
#:nodoc:
def
filtering_parameters?
#:nodoc:
@env
[
"action_dispatch.parameter_filter"
].
present?
end
def
process_parameter_filter
(
params
)
#:nodoc:
compiled_parameter_filter_for
(
@env
[
"action_dispatch.parameter_filter"
]).
call
(
params
)
end
def
compile_parameter_filter
(
filters
)
#:nodoc:
strings
,
regexps
,
blocks
=
[],
[],
[]
Array
(
@env
[
"action_dispatch.parameter_filter"
])
.
each
do
|
item
|
filters
.
each
do
|
item
|
case
item
when
NilClass
when
Proc
...
...
@@ -65,15 +80,12 @@ def compile_parameter_filter #:nodoc:
[
regexps
,
blocks
]
end
def
filtering_parameters?
#:nodoc:
@env
[
"action_dispatch.parameter_filter"
].
present?
end
def
process_parameter_filter
(
original_params
)
#:nodoc:
return
original_params
.
dup
unless
filtering_parameters?
def
compiled_parameter_filter_for
(
filters
)
#:nodoc:
@@compiled_parameter_filter_for
[
filters
]
||=
begin
regexps
,
blocks
=
compile_parameter_filter
(
filters
)
lambda
do
|
original_params
|
filtered_params
=
{}
regexps
,
blocks
=
compile_parameter_filter
original_params
.
each
do
|
key
,
value
|
if
regexps
.
find
{
|
r
|
key
=~
r
}
...
...
@@ -81,7 +93,7 @@ def process_parameter_filter(original_params) #:nodoc:
elsif
value
.
is_a?
(
Hash
)
value
=
process_parameter_filter
(
value
)
elsif
value
.
is_a?
(
Array
)
value
=
value
.
map
{
|
i
|
process_parameter_filter
(
i
)
}
value
=
value
.
map
{
|
v
|
v
.
is_a?
(
Hash
)
?
process_parameter_filter
(
v
)
:
v
}
elsif
blocks
.
present?
key
=
key
.
dup
value
=
value
.
dup
if
value
.
duplicable?
...
...
@@ -95,4 +107,7 @@ def process_parameter_filter(original_params) #:nodoc:
end
end
end
end
end
end
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录