Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
b2be83fc
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,发现更多精彩内容 >>
未验证
提交
b2be83fc
编写于
12月 18, 2017
作者:
E
Eileen M. Uchitelle
提交者:
GitHub
12月 18, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #31490 from eugeneius/hash_digest_class_truncate
Don't include ellipsis in truncated digest output
上级
95117a2c
b9e7c676
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
7 addition
and
15 deletion
+7
-15
activesupport/CHANGELOG.md
activesupport/CHANGELOG.md
+3
-3
activesupport/lib/active_support/digest.rb
activesupport/lib/active_support/digest.rb
+1
-9
activesupport/lib/active_support/railtie.rb
activesupport/lib/active_support/railtie.rb
+2
-2
activesupport/test/digest_test.rb
activesupport/test/digest_test.rb
+1
-1
未找到文件。
activesupport/CHANGELOG.md
浏览文件 @
b2be83fc
*
Introduced
`ActiveSupport::Digest`
that allows to specify hash function implementation
and defaults to
`Digest::MD5
`
.
*
Allow the hash function used to generate non-sensitive digests, such as the
ETag header, to be specified with
`config.active_support.hash_digest_class
`
.
Replaced calls to `::Digest::MD5.hexdigest` with calls to `ActiveSupport::Digest.hexdigest
`.
The object provided must respond to `#hexdigest`, e.g. `Digest::SHA1
`.
*Dmitri Dolguikh*
...
...
activesupport/lib/active_support/digest.rb
浏览文件 @
b2be83fc
...
...
@@ -13,16 +13,8 @@ def hash_digest_class=(klass)
end
def
hexdigest
(
arg
)
new
.
hexdigest
(
arg
)
hash_digest_class
.
hexdigest
(
arg
)[
0
...
32
]
end
end
def
initialize
(
digest_class:
nil
)
@digest_class
=
digest_class
||
self
.
class
.
hash_digest_class
end
def
hexdigest
(
arg
)
@digest_class
.
hexdigest
(
arg
).
truncate
(
32
)
end
end
end
activesupport/lib/active_support/railtie.rb
浏览文件 @
b2be83fc
...
...
@@ -68,9 +68,9 @@ class Railtie < Rails::Railtie # :nodoc:
end
initializer
"active_support.set_hash_digest_class"
do
|
app
|
if
app
.
config
.
active_support
.
respond_to?
(
:
use_hash_digest_class
)
&&
app
.
config
.
active_support
.
use_
hash_digest_class
if
app
.
config
.
active_support
.
respond_to?
(
:
hash_digest_class
)
&&
app
.
config
.
active_support
.
hash_digest_class
ActiveSupport
::
Digest
.
hash_digest_class
=
app
.
config
.
active_support
.
use_
hash_digest_class
app
.
config
.
active_support
.
hash_digest_class
end
end
end
...
...
activesupport/test/digest_test.rb
浏览文件 @
b2be83fc
...
...
@@ -16,7 +16,7 @@ def test_with_custom_hash_digest_class
digest
=
ActiveSupport
::
Digest
.
hexdigest
(
"hello friend"
)
assert_equal
32
,
digest
.
length
assert_equal
::
Digest
::
SHA1
.
hexdigest
(
"hello friend"
)
.
truncate
(
32
)
,
digest
assert_equal
::
Digest
::
SHA1
.
hexdigest
(
"hello friend"
)
[
0
...
32
]
,
digest
ensure
ActiveSupport
::
Digest
.
hash_digest_class
=
original_hash_digest_class
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录