Skip to content

Commit 122a32c

Browse files
committed
fix(strict-mode): make regexes more rigid
1 parent 4acad30 commit 122a32c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ const Transform = require('stream').Transform
55

66
const SPEC_ALGORITHMS = ['sha256', 'sha384', 'sha512']
77

8-
const BASE64_REGEX = /[a-z0-9+/]+(?:=?=?)/i
8+
const BASE64_REGEX = /^[a-z0-9+/]+(?:=?=?)$/i
99
const SRI_REGEX = /^([^-]+)-([^?]+)([?\S*]*)$/
1010
const STRICT_SRI_REGEX = /^([^-]+)-([A-Za-z0-9+/]+(?:=?=?))([?\x21-\x7E]*)$/
11-
const VCHAR_REGEX = /[\x21-\x7E]+/
11+
const VCHAR_REGEX = /^[\x21-\x7E]+$/
1212

1313
class IntegrityMetadata {
1414
constructor (metadata, opts) {
@@ -75,7 +75,7 @@ class Integrity {
7575
const other = typeof integrity === 'string'
7676
? integrity
7777
: stringify(integrity, opts)
78-
return parse(`${this.toString()} ${other}`, opts)
78+
return parse(`${this.toString(opts)} ${other}`, opts)
7979
}
8080
}
8181

0 commit comments

Comments
 (0)