Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
c4d570c2
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,发现更多精彩内容 >>
提交
c4d570c2
编写于
6月 04, 2008
作者:
J
Joshua Peek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use CGI::Cookie::parse for request cookies until we officially deprecated CGI.
上级
5fe28789
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
8 addition
and
42 deletion
+8
-42
actionpack/lib/action_controller/rack_process.rb
actionpack/lib/action_controller/rack_process.rb
+4
-38
actionpack/test/controller/rack_test.rb
actionpack/test/controller/rack_test.rb
+4
-4
未找到文件。
actionpack/lib/action_controller/rack_process.rb
浏览文件 @
c4d570c2
...
@@ -49,21 +49,12 @@ def request_parameters
...
@@ -49,21 +49,12 @@ def request_parameters
def
cookies
def
cookies
return
{}
unless
@env
[
"HTTP_COOKIE"
]
return
{}
unless
@env
[
"HTTP_COOKIE"
]
if
@env
[
"rack.request.cookie_string"
]
==
@env
[
"HTTP_COOKIE"
]
unless
@env
[
"rack.request.cookie_string"
]
==
@env
[
"HTTP_COOKIE"
]
@env
[
"rack.request.cookie_hash"
]
else
@env
[
"rack.request.cookie_string"
]
=
@env
[
"HTTP_COOKIE"
]
@env
[
"rack.request.cookie_string"
]
=
@env
[
"HTTP_COOKIE"
]
# According to RFC 2109:
@env
[
"rack.request.cookie_hash"
]
=
CGI
::
Cookie
::
parse
(
@env
[
"rack.request.cookie_string"
])
# If multiple cookies satisfy the criteria above, they are ordered in
# the Cookie header such that those with more specific Path attributes
# precede those with less specific. Ordering with respect to other
# attributes (e.g., Domain) is unspecified.
@env
[
"rack.request.cookie_hash"
]
=
parse_query
(
@env
[
"rack.request.cookie_string"
],
';,'
).
inject
({})
{
|
h
,
(
k
,
v
)
|
h
[
k
]
=
Array
===
v
?
v
.
first
:
v
h
}
end
end
@env
[
"rack.request.cookie_hash"
]
end
end
def
host_with_port_without_standard_port_handling
def
host_with_port_without_standard_port_handling
...
@@ -170,31 +161,6 @@ def stale_session_check!
...
@@ -170,31 +161,6 @@ def stale_session_check!
def
session_options_with_string_keys
def
session_options_with_string_keys
@session_options_with_string_keys
||=
DEFAULT_SESSION_OPTIONS
.
merge
(
@session_options
).
stringify_keys
@session_options_with_string_keys
||=
DEFAULT_SESSION_OPTIONS
.
merge
(
@session_options
).
stringify_keys
end
end
# From Rack::Utils
def
parse_query
(
qs
,
d
=
'&;'
)
params
=
{}
(
qs
||
''
).
split
(
/[
#{
d
}
] */n
).
inject
(
params
)
{
|
h
,
p
|
k
,
v
=
unescape
(
p
).
split
(
'='
,
2
)
if
cur
=
params
[
k
]
if
cur
.
class
==
Array
params
[
k
]
<<
v
else
params
[
k
]
=
[
cur
,
v
]
end
else
params
[
k
]
=
v
end
}
return
params
end
def
unescape
(
s
)
s
.
tr
(
'+'
,
' '
).
gsub
(
/((?:%[0-9a-fA-F]{2})+)/n
){
[
$1
.
delete
(
'%'
)].
pack
(
'H*'
)
}
end
end
end
class
RackResponse
<
AbstractResponse
#:nodoc:
class
RackResponse
<
AbstractResponse
#:nodoc:
...
...
actionpack/test/controller/rack_test.rb
浏览文件 @
c4d570c2
...
@@ -33,10 +33,10 @@ def setup
...
@@ -33,10 +33,10 @@ def setup
"REDIRECT_STATUS"
=>
"200"
,
"REDIRECT_STATUS"
=>
"200"
,
"REQUEST_METHOD"
=>
"GET"
"REQUEST_METHOD"
=>
"GET"
}
}
@request
=
ActionController
::
RackRequest
.
new
(
@env
)
# some Nokia phone browsers omit the space after the semicolon separator.
# some Nokia phone browsers omit the space after the semicolon separator.
# some developers have grown accustomed to using comma in cookie values.
# some developers have grown accustomed to using comma in cookie values.
@alt_cookie_fmt_request_hash
=
{
"HTTP_COOKIE"
=>
"_session_id=c84ace847,96670c052c6ceb2451fb0f2;is_admin=yes"
}
@alt_cookie_fmt_request
=
ActionController
::
RackRequest
.
new
(
@env
.
merge
({
"HTTP_COOKIE"
=>
"_session_id=c84ace847,96670c052c6ceb2451fb0f2;is_admin=yes"
}))
@request
=
ActionController
::
RackRequest
.
new
(
@env
)
end
end
def
default_test
;
end
def
default_test
;
end
...
@@ -100,11 +100,11 @@ def test_host_if_ipv6_reference_with_port
...
@@ -100,11 +100,11 @@ def test_host_if_ipv6_reference_with_port
end
end
def
test_cookie_syntax_resilience
def
test_cookie_syntax_resilience
cookies
=
CGI
::
Cookie
::
parse
(
@env
[
"HTTP_COOKIE"
]);
cookies
=
@request
.
cookies
assert_equal
[
"c84ace84796670c052c6ceb2451fb0f2"
],
cookies
[
"_session_id"
],
cookies
.
inspect
assert_equal
[
"c84ace84796670c052c6ceb2451fb0f2"
],
cookies
[
"_session_id"
],
cookies
.
inspect
assert_equal
[
"yes"
],
cookies
[
"is_admin"
],
cookies
.
inspect
assert_equal
[
"yes"
],
cookies
[
"is_admin"
],
cookies
.
inspect
alt_cookies
=
CGI
::
Cookie
::
parse
(
@alt_cookie_fmt_request_hash
[
"HTTP_COOKIE"
]);
alt_cookies
=
@alt_cookie_fmt_request
.
cookies
assert_equal
[
"c84ace847,96670c052c6ceb2451fb0f2"
],
alt_cookies
[
"_session_id"
],
alt_cookies
.
inspect
assert_equal
[
"c84ace847,96670c052c6ceb2451fb0f2"
],
alt_cookies
[
"_session_id"
],
alt_cookies
.
inspect
assert_equal
[
"yes"
],
alt_cookies
[
"is_admin"
],
alt_cookies
.
inspect
assert_equal
[
"yes"
],
alt_cookies
[
"is_admin"
],
alt_cookies
.
inspect
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录