You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
consterr=newError(`stream size mismatch when checking ${this.sri}.\n Wanted: ${this.expectedSize}\n Found: ${this.size}`)
104
110
err.code='EBADSIZE'
105
111
err.found=this.size
106
112
err.expected=this.expectedSize
107
113
err.sri=this.sri
108
114
this.emit('error',err)
109
115
}elseif(this.sri&&!match){
110
-
/* eslint-disable-next-line max-len */
111
116
consterr=newError(`${this.sri} integrity checksum failed when using ${this.algorithm}: wanted ${this.digests} but got ${newSri}. (${this.size} bytes)`)
112
117
err.code='EINTEGRITY'
113
118
err.found=newSri
@@ -137,8 +142,7 @@ class Hash {
137
142
conststrict=opts?.strict
138
143
this.source=hash.trim()
139
144
140
-
// set default values so that we make V8 happy to
141
-
// always see a familiar object template.
145
+
// set default values so that we make V8 happy to always see a familiar object template.
142
146
this.digest=''
143
147
this.algorithm=''
144
148
this.options=[]
@@ -156,6 +160,9 @@ class Hash {
156
160
if(strict&&!SPEC_ALGORITHMS.includes(match[1])){
157
161
return
158
162
}
163
+
if(!NODE_HASHES.includes(match[1])){
164
+
return
165
+
}
159
166
this.algorithm=match[1]
160
167
this.digest=match[2]
161
168
@@ -198,15 +205,12 @@ class Hash {
198
205
199
206
toString(opts){
200
207
if(opts?.strict){
201
-
// Strict mode enforces the standard as close to the foot of the
202
-
// letter as it can.
208
+
// Strict mode enforces the standard as close to the foot of the letter as it can.
203
209
if(!(
204
210
// The spec has very restricted productions for algorithms.
205
211
// https://www.w3.org/TR/CSP2/#source-list-syntax
206
212
SPEC_ALGORITHMS.includes(this.algorithm)&&
207
-
// Usually, if someone insists on using a "different" base64, we
208
-
// leave it as-is, since there's multiple standards, and the
209
-
// specified is not a URL-safe variant.
213
+
// Usually, if someone insists on using a "different" base64, we leave it as-is, since there are multiple standards, and the specified is not a URL-safe variant.
210
214
// https://www.w3.org/TR/CSP2/#base64_value
211
215
this.digest.match(BASE64_REGEX)&&
212
216
// Option syntax is strictly visual chars.
@@ -300,8 +304,7 @@ class Integrity {
300
304
returnparse(this,{single: true}).hexDigest()
301
305
}
302
306
303
-
// add additional hashes to an integrity value, but prevent
304
-
// *changing* an existing integrity hash.
307
+
// add additional hashes to an integrity value, but prevent *changing* an existing integrity hash.
0 commit comments