Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/ssriPublic

Commitb30dfdb

Browse files
committed
fix: backport regex change from 8.0.1
PR-URL:#19Credit:@nlfClose:#19Reviewed-by:@wraithgar
1 parenta4337cd commitb30dfdb

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

‎index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const SPEC_ALGORITHMS = ['sha256', 'sha384', 'sha512']
88

99
constBASE64_REGEX=/^[a-z0-9+/]+(?:=?=?)$/i
1010
constSRI_REGEX=/^([^-]+)-([^?]+)([?\S*]*)$/
11-
constSTRICT_SRI_REGEX=/^([^-]+)-([A-Za-z0-9+/=]{44,88})(\?[\x21-\x7E]*)*$/
11+
constSTRICT_SRI_REGEX=/^([^-]+)-([A-Za-z0-9+/=]{44,88})(\?[\x21-\x7E]*)?$/
1212
constVCHAR_REGEX=/^[\x21-\x7E]+$/
1313

1414
constSsriOpts=figgyPudding({

‎test/parse.js‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,34 @@ test('parses single-entry integrity string', t => {
2626
t.done()
2727
})
2828

29+
test('parses options from integrity string',t=>{
30+
constsha=hash(TEST_DATA,'sha512')
31+
constintegrity=`sha512-${sha}?one?two?three`
32+
t.deepEqual(ssri.parse(integrity),{
33+
sha512:[{
34+
source:integrity,
35+
digest:sha,
36+
algorithm:'sha512',
37+
options:['one','two','three']
38+
}]
39+
},'single entry parsed into full Integrity instance')
40+
t.done()
41+
})
42+
43+
test('parses options from integrity string in strict mode',t=>{
44+
constsha=hash(TEST_DATA,'sha512')
45+
constintegrity=`sha512-${sha}?one?two?three`
46+
t.deepEqual(ssri.parse(integrity,{strict:true}),{
47+
sha512:[{
48+
source:integrity,
49+
digest:sha,
50+
algorithm:'sha512',
51+
options:['one','two','three']
52+
}]
53+
},'single entry parsed into full Integrity instance')
54+
t.done()
55+
})
56+
2957
test('can parse single-entry string directly into Hash',t=>{
3058
constsha=hash(TEST_DATA,'sha512')
3159
constintegrity=`sha512-${sha}`

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp