diff --git a/CHANGELOG.md b/CHANGELOG.md index d4c5897..15c930b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [6.0.2](https://github.com/zkat/ssri/compare/v6.0.1...v6.0.2) (2021-04-07) + + +### Bug Fixes + +* backport regex change from 8.0.1 ([b30dfdb](https://github.com/zkat/ssri/commit/b30dfdb)), closes [#19](https://github.com/zkat/ssri/issues/19) + + + ## [6.0.1](https://github.com/zkat/ssri/compare/v6.0.0...v6.0.1) (2018-08-27) diff --git a/index.js b/index.js index e102892..673ed2a 100644 --- a/index.js +++ b/index.js @@ -8,7 +8,7 @@ const SPEC_ALGORITHMS = ['sha256', 'sha384', 'sha512'] const BASE64_REGEX = /^[a-z0-9+/]+(?:=?=?)$/i const SRI_REGEX = /^([^-]+)-([^?]+)([?\S*]*)$/ -const STRICT_SRI_REGEX = /^([^-]+)-([A-Za-z0-9+/=]{44,88})(\?[\x21-\x7E]*)*$/ +const STRICT_SRI_REGEX = /^([^-]+)-([A-Za-z0-9+/=]{44,88})(\?[\x21-\x7E]*)?$/ const VCHAR_REGEX = /^[\x21-\x7E]+$/ const SsriOpts = figgyPudding({ diff --git a/package-lock.json b/package-lock.json index f6bfb35..3925ca3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ssri", - "version": "6.0.1", + "version": "6.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index b686344..b496c7f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ssri", - "version": "6.0.1", + "version": "6.0.2", "description": "Standard Subresource Integrity library -- parses, serializes, generates, and verifies integrity metadata according to the SRI spec.", "main": "index.js", "files": [ diff --git a/test/parse.js b/test/parse.js index cad5a88..77338d4 100644 --- a/test/parse.js +++ b/test/parse.js @@ -26,6 +26,34 @@ test('parses single-entry integrity string', t => { t.done() }) +test('parses options from integrity string', t => { + const sha = hash(TEST_DATA, 'sha512') + const integrity = `sha512-${sha}?one?two?three` + t.deepEqual(ssri.parse(integrity), { + sha512: [{ + source: integrity, + digest: sha, + algorithm: 'sha512', + options: ['one', 'two', 'three'] + }] + }, 'single entry parsed into full Integrity instance') + t.done() +}) + +test('parses options from integrity string in strict mode', t => { + const sha = hash(TEST_DATA, 'sha512') + const integrity = `sha512-${sha}?one?two?three` + t.deepEqual(ssri.parse(integrity, { strict: true }), { + sha512: [{ + source: integrity, + digest: sha, + algorithm: 'sha512', + options: ['one', 'two', 'three'] + }] + }, 'single entry parsed into full Integrity instance') + t.done() +}) + test('can parse single-entry string directly into Hash', t => { const sha = hash(TEST_DATA, 'sha512') const integrity = `sha512-${sha}`