| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -501,8 +501,10 @@ class Manifest { | |||
| 501 | 501 | value: expected | |
| 502 | 502 | } = integrityEntries[i]; | |
| 503 | 503 | const hash = createHash(algorithm); | |
| 504 | - HashUpdate(hash, content); | ||
| 505 | - const digest = HashDigest(hash); | ||
| 504 | + // TODO(tniessen): the content should not be passed as a string in the | ||
| 505 | + // first place, see https://github.com/nodejs/node/issues/39707 | ||
| 506 | + HashUpdate(hash, content, 'utf8'); | ||
| 507 | + const digest = HashDigest(hash, 'buffer'); | ||
| 506 | 508 | if (digest.length === expected.length && | |
| 507 | 509 | timingSafeEqual(digest, expected)) { | |
| 508 | 510 | return true; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + *.js text eol=lf | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + // No code. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,4 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + require('crypto').DEFAULT_ENCODING = process.env.DEFAULT_ENCODING; | ||
| 4 | + require('./dep.js'); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,14 @@ | |||
| 1 | + { | ||
| 2 | + "resources": { | ||
| 3 | + "./parent.js": { | ||
| 4 | + "integrity": "sha384-j4pMdq83q5Bq9+idcHuGKzi89FrYm1PhZYrEw3irbNob6g4i3vKBjfYiRNYwmoGr", | ||
| 5 | + "dependencies": { | ||
| 6 | + "crypto": true, | ||
| 7 | + "./dep.js": true | ||
| 8 | + } | ||
| 9 | + }, | ||
| 10 | + "./dep.js": { | ||
| 11 | + "integrity": "sha384-VU7GIrTix/HFLhUb4yqsV4n1xXqjPcWw6kLvjuKXtR1+9nmufJu5vZLajBs8brIW" | ||
| 12 | + } | ||
| 13 | + } | ||
| 14 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,34 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + if (!common.hasCrypto) | ||
| 5 | + common.skip('missing crypto'); | ||
| 6 | + common.requireNoPackageJSONAbove(); | ||
| 7 | + | ||
| 8 | + const fixtures = require('../common/fixtures'); | ||
| 9 | + | ||
| 10 | + const assert = require('assert'); | ||
| 11 | + const { spawnSync } = require('child_process'); | ||
| 12 | + | ||
| 13 | + const encodings = ['buffer', 'utf8', 'utf16le', 'latin1', 'base64', 'hex']; | ||
| 14 | + | ||
| 15 | + for (const encoding of encodings) { | ||
| 16 | + const dep = fixtures.path('policy', 'crypto-default-encoding', 'parent.js'); | ||
| 17 | + const depPolicy = fixtures.path( | ||
| 18 | + 'policy', | ||
| 19 | + 'crypto-default-encoding', | ||
| 20 | + 'policy.json'); | ||
| 21 | + const { status } = spawnSync( | ||
| 22 | + process.execPath, | ||
| 23 | + [ | ||
| 24 | + '--experimental-policy', depPolicy, dep, | ||
| 25 | + ], | ||
| 26 | + { | ||
| 27 | + env: { | ||
| 28 | + ...process.env, | ||
| 29 | + DEFAULT_ENCODING: encoding | ||
| 30 | + } | ||
| 31 | + } | ||
| 32 | + ); | ||
| 33 | + assert.strictEqual(status, 0); | ||
| 34 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments