isomorphic-git 1.43.1 → 1.43.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -459,6 +459,10 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
459
459
  <td align="center"><a href="https://github.com/MadalinTurluianu"><img src="https://avatars.githubusercontent.com/u/81984912?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Madalin Turluianu</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=MadalinTurluianu" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=MadalinTurluianu" title="Tests">⚠️</a></td>
460
460
  <td align="center"><a href="https://nandan.fyi"><img src="https://avatars.githubusercontent.com/u/74198723?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Nandan Varma</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=nandan-varma" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=nandan-varma" title="Tests">⚠️</a></td>
461
461
  </tr>
462
+ <tr>
463
+ <td align="center"><a href="https://github.com/ewraj"><img src="https://avatars.githubusercontent.com/u/212665522?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Raj Royal</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=ewraj" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=ewraj" title="Tests">⚠️</a></td>
464
+ <td align="center"><a href="https://github.com/macabeus"><img src="https://avatars.githubusercontent.com/u/9501115?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Bruno Macabeus</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=macabeus" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=macabeus" title="Tests">⚠️</a></td>
465
+ </tr>
462
466
  </table>
463
467
 
464
468
  <!-- markdownlint-restore -->
package/index.cjs CHANGED
@@ -1831,8 +1831,9 @@ const SECTION_REGEX = /^[A-Za-z0-9-.]+$/;
1831
1831
  // variable name is alphanumeric (ASCII) with -
1832
1832
  // variable name starts with an alphabetic character
1833
1833
  // variable name is case insensitive
1834
- const VARIABLE_LINE_REGEX = /^([A-Za-z][A-Za-z-]*)(?: *= *(.*))?$/;
1835
- const VARIABLE_NAME_REGEX = /^[A-Za-z][A-Za-z-]*$/;
1834
+ // whitespace (spaces or tabs) around the equal sign is ignored
1835
+ const VARIABLE_LINE_REGEX = /^([A-Za-z][A-Za-z0-9-]*)(?:\s*=\s*(.*))?$/;
1836
+ const VARIABLE_NAME_REGEX = /^[A-Za-z][A-Za-z0-9-]*$/;
1836
1837
 
1837
1838
  // Comments start with either # or ; and extend to the end of line
1838
1839
  const VARIABLE_VALUE_COMMENT_REGEX = /^(.*?)( *[#;].*)$/;
@@ -3717,37 +3718,12 @@ async function readObjectPacked({
3717
3718
  }
3718
3719
 
3719
3720
  // === Packfile Integrity Verification ===
3720
- // Performance optimization: use _checksumVerified flag to verify only once per packfile
3721
- if (!p._checksumVerified) {
3722
- const expectedShaFromIndex = p.packfileSha;
3723
-
3724
- // 1. Fast Check: Verify packfile trailer matches index record
3725
- // Use subarray instead of slice to avoid memory copy (zero-copy for large packfiles)
3726
- const packTrailer = pack.subarray(-20);
3727
- const packTrailerSha = Array.from(packTrailer)
3728
- .map(b => b.toString(16).padStart(2, '0'))
3729
- .join('');
3730
- if (packTrailerSha !== expectedShaFromIndex) {
3731
- throw new InternalError(
3732
- `Packfile trailer mismatch: expected ${expectedShaFromIndex}, got ${packTrailerSha}. The packfile may be corrupted.`
3733
- )
3734
- }
3735
-
3736
- // 2. Deep Integrity Check: Calculate actual SHA-1 of packfile payload.
3737
- // The Node package build swaps in a chunked implementation for large packs.
3738
- const actualPayloadSha = await shasumRange(pack, {
3739
- start: 0,
3740
- end: pack.length - 20,
3741
- });
3742
- if (actualPayloadSha !== expectedShaFromIndex) {
3743
- throw new InternalError(
3744
- `Packfile payload corrupted: calculated ${actualPayloadSha} but expected ${expectedShaFromIndex}. The packfile may have been tampered with.`
3745
- )
3746
- }
3747
-
3748
- // Mark as verified to prevent performance regression on subsequent reads
3749
- p._checksumVerified = true;
3721
+ // Performance optimization: verify only once per packfile.
3722
+ // Concurrent reads share the same verification promise.
3723
+ if (!p._checksumVerification) {
3724
+ p._checksumVerification = verifyPackfile(pack, p.packfileSha);
3750
3725
  }
3726
+ await p._checksumVerification;
3751
3727
 
3752
3728
  const result = await p.read({ oid, getExternalRefDelta });
3753
3729
  result.format = 'content';
@@ -3759,6 +3735,32 @@ async function readObjectPacked({
3759
3735
  return null
3760
3736
  }
3761
3737
 
3738
+ async function verifyPackfile(pack, expectedShaFromIndex) {
3739
+ // 1. Fast Check: Verify packfile trailer matches index record
3740
+ // Use subarray instead of slice to avoid memory copy (zero-copy for large packfiles)
3741
+ const packTrailer = pack.subarray(-20);
3742
+ const packTrailerSha = Array.from(packTrailer)
3743
+ .map(b => b.toString(16).padStart(2, '0'))
3744
+ .join('');
3745
+ if (packTrailerSha !== expectedShaFromIndex) {
3746
+ throw new InternalError(
3747
+ `Packfile trailer mismatch: expected ${expectedShaFromIndex}, got ${packTrailerSha}. The packfile may be corrupted.`
3748
+ )
3749
+ }
3750
+
3751
+ // 2. Deep Integrity Check: Calculate actual SHA-1 of packfile payload.
3752
+ // The Node package build swaps in a chunked implementation for large packs.
3753
+ const actualPayloadSha = await shasumRange(pack, {
3754
+ start: 0,
3755
+ end: pack.length - 20,
3756
+ });
3757
+ if (actualPayloadSha !== expectedShaFromIndex) {
3758
+ throw new InternalError(
3759
+ `Packfile payload corrupted: calculated ${actualPayloadSha} but expected ${expectedShaFromIndex}. The packfile may have been tampered with.`
3760
+ )
3761
+ }
3762
+ }
3763
+
3762
3764
  /**
3763
3765
  * @param {object} args
3764
3766
  * @param {import('../models/FileSystem.js').FileSystem} args.fs
@@ -10054,8 +10056,8 @@ function filterCapabilities(server, client) {
10054
10056
 
10055
10057
  const pkg = {
10056
10058
  name: 'isomorphic-git',
10057
- version: '1.43.1',
10058
- agent: 'git/isomorphic-git@1.43.1',
10059
+ version: '1.43.3',
10060
+ agent: 'git/isomorphic-git@1.43.3',
10059
10061
  };
10060
10062
 
10061
10063
  class FIFO {
package/index.js CHANGED
@@ -1824,8 +1824,9 @@ const SECTION_REGEX = /^[A-Za-z0-9-.]+$/;
1824
1824
  // variable name is alphanumeric (ASCII) with -
1825
1825
  // variable name starts with an alphabetic character
1826
1826
  // variable name is case insensitive
1827
- const VARIABLE_LINE_REGEX = /^([A-Za-z][A-Za-z-]*)(?: *= *(.*))?$/;
1828
- const VARIABLE_NAME_REGEX = /^[A-Za-z][A-Za-z-]*$/;
1827
+ // whitespace (spaces or tabs) around the equal sign is ignored
1828
+ const VARIABLE_LINE_REGEX = /^([A-Za-z][A-Za-z0-9-]*)(?:\s*=\s*(.*))?$/;
1829
+ const VARIABLE_NAME_REGEX = /^[A-Za-z][A-Za-z0-9-]*$/;
1829
1830
 
1830
1831
  // Comments start with either # or ; and extend to the end of line
1831
1832
  const VARIABLE_VALUE_COMMENT_REGEX = /^(.*?)( *[#;].*)$/;
@@ -3704,37 +3705,12 @@ async function readObjectPacked({
3704
3705
  }
3705
3706
 
3706
3707
  // === Packfile Integrity Verification ===
3707
- // Performance optimization: use _checksumVerified flag to verify only once per packfile
3708
- if (!p._checksumVerified) {
3709
- const expectedShaFromIndex = p.packfileSha;
3710
-
3711
- // 1. Fast Check: Verify packfile trailer matches index record
3712
- // Use subarray instead of slice to avoid memory copy (zero-copy for large packfiles)
3713
- const packTrailer = pack.subarray(-20);
3714
- const packTrailerSha = Array.from(packTrailer)
3715
- .map(b => b.toString(16).padStart(2, '0'))
3716
- .join('');
3717
- if (packTrailerSha !== expectedShaFromIndex) {
3718
- throw new InternalError(
3719
- `Packfile trailer mismatch: expected ${expectedShaFromIndex}, got ${packTrailerSha}. The packfile may be corrupted.`
3720
- )
3721
- }
3722
-
3723
- // 2. Deep Integrity Check: Calculate actual SHA-1 of packfile payload.
3724
- // The Node package build swaps in a chunked implementation for large packs.
3725
- const actualPayloadSha = await shasumRange(pack, {
3726
- start: 0,
3727
- end: pack.length - 20,
3728
- });
3729
- if (actualPayloadSha !== expectedShaFromIndex) {
3730
- throw new InternalError(
3731
- `Packfile payload corrupted: calculated ${actualPayloadSha} but expected ${expectedShaFromIndex}. The packfile may have been tampered with.`
3732
- )
3733
- }
3734
-
3735
- // Mark as verified to prevent performance regression on subsequent reads
3736
- p._checksumVerified = true;
3708
+ // Performance optimization: verify only once per packfile.
3709
+ // Concurrent reads share the same verification promise.
3710
+ if (!p._checksumVerification) {
3711
+ p._checksumVerification = verifyPackfile(pack, p.packfileSha);
3737
3712
  }
3713
+ await p._checksumVerification;
3738
3714
 
3739
3715
  const result = await p.read({ oid, getExternalRefDelta });
3740
3716
  result.format = 'content';
@@ -3746,6 +3722,32 @@ async function readObjectPacked({
3746
3722
  return null
3747
3723
  }
3748
3724
 
3725
+ async function verifyPackfile(pack, expectedShaFromIndex) {
3726
+ // 1. Fast Check: Verify packfile trailer matches index record
3727
+ // Use subarray instead of slice to avoid memory copy (zero-copy for large packfiles)
3728
+ const packTrailer = pack.subarray(-20);
3729
+ const packTrailerSha = Array.from(packTrailer)
3730
+ .map(b => b.toString(16).padStart(2, '0'))
3731
+ .join('');
3732
+ if (packTrailerSha !== expectedShaFromIndex) {
3733
+ throw new InternalError(
3734
+ `Packfile trailer mismatch: expected ${expectedShaFromIndex}, got ${packTrailerSha}. The packfile may be corrupted.`
3735
+ )
3736
+ }
3737
+
3738
+ // 2. Deep Integrity Check: Calculate actual SHA-1 of packfile payload.
3739
+ // The Node package build swaps in a chunked implementation for large packs.
3740
+ const actualPayloadSha = await shasumRange(pack, {
3741
+ start: 0,
3742
+ end: pack.length - 20,
3743
+ });
3744
+ if (actualPayloadSha !== expectedShaFromIndex) {
3745
+ throw new InternalError(
3746
+ `Packfile payload corrupted: calculated ${actualPayloadSha} but expected ${expectedShaFromIndex}. The packfile may have been tampered with.`
3747
+ )
3748
+ }
3749
+ }
3750
+
3749
3751
  /**
3750
3752
  * @param {object} args
3751
3753
  * @param {import('../models/FileSystem.js').FileSystem} args.fs
@@ -10041,8 +10043,8 @@ function filterCapabilities(server, client) {
10041
10043
 
10042
10044
  const pkg = {
10043
10045
  name: 'isomorphic-git',
10044
- version: '1.43.1',
10045
- agent: 'git/isomorphic-git@1.43.1',
10046
+ version: '1.43.3',
10047
+ agent: 'git/isomorphic-git@1.43.3',
10046
10048
  };
10047
10049
 
10048
10050
  class FIFO {