isomorphic-git 1.38.6 → 1.38.8

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/index.cjs CHANGED
@@ -2541,13 +2541,19 @@ function parseBuffer(buffer) {
2541
2541
  // "." and ".." (which resolve outside the working directory), and ".git" (which git
2542
2542
  // disallows as a path component). Checks mirror git's is_ntfs_dotgit() and
2543
2543
  // is_hfs_dotgit(): case-insensitive, trailing dots/spaces stripped (NTFS),
2544
- // NTFS 8.3 short name aliases (git~1..git~9), and HFS+ ignorable Unicode
2545
- // characters stripped (zero-width joiners, directional marks, BOM, etc.).
2544
+ // NTFS 8.3 short name aliases (git~1..git~9), NTFS Alternate Data Streams, and
2545
+ // HFS+ ignorable Unicode characters stripped (zero-width joiners, directional
2546
+ // marks, BOM, etc.).
2546
2547
  const hfsClean = path.replace(
2547
2548
  /[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/g,
2548
2549
  ''
2549
2550
  );
2550
- const normalized = hfsClean.toLowerCase().replace(/[. ]+$/, '');
2551
+ // NTFS Alternate Data Streams are referenced as `<name>:<stream>:<type>`, and a
2552
+ // directory's default stream lets `.git::$INDEX_ALLOCATION` resolve to the `.git`
2553
+ // directory itself. git forbids *any* ADS, so only the portion before the first
2554
+ // colon names the actual entry we normalize and check.
2555
+ const ntfsClean = hfsClean.split(':')[0];
2556
+ const normalized = ntfsClean.toLowerCase().replace(/[. ]+$/, '');
2551
2557
  if (
2552
2558
  path.includes('\\') ||
2553
2559
  path.includes('/') ||
@@ -6884,23 +6890,11 @@ async function branch({
6884
6890
  }
6885
6891
  }
6886
6892
 
6887
- const worthWalking = (filepath, root) => {
6888
- if (filepath === '.' || root == null || root.length === 0 || root === '.') {
6889
- return true
6890
- }
6891
- if (root.length >= filepath.length) {
6892
- return root.startsWith(filepath)
6893
- } else {
6894
- return filepath.startsWith(root)
6895
- }
6896
- };
6897
-
6898
- // @ts-check
6899
-
6900
6893
  /**
6901
- * Throw if any leading directory component of `fullpath` (relative to `dir`) is a symbolic
6902
- * link. git does not follow symlinks in the leading path when writing working-tree files;
6903
- * matching that avoids writing through a symlinked parent into a location outside `dir`.
6894
+ * Refuse to materialize a working-tree entry whose parent path traverses a
6895
+ * symbolic link. A leading component that is a symlink could otherwise redirect
6896
+ * a write or mkdir outside the working tree. git applies the same check: it does
6897
+ * not follow symlinks in the leading path when writing working-tree files.
6904
6898
  *
6905
6899
  * @param {import('../models/FileSystem.js').FileSystem} fs
6906
6900
  * @param {string} dir
@@ -6921,6 +6915,19 @@ async function assertNoSymlinkInLeadingPath(fs, dir, fullpath) {
6921
6915
  }
6922
6916
  }
6923
6917
 
6918
+ const worthWalking = (filepath, root) => {
6919
+ if (filepath === '.' || root == null || root.length === 0 || root === '.') {
6920
+ return true
6921
+ }
6922
+ if (root.length >= filepath.length) {
6923
+ return root.startsWith(filepath)
6924
+ } else {
6925
+ return filepath.startsWith(root)
6926
+ }
6927
+ };
6928
+
6929
+ // @ts-check
6930
+
6924
6931
  /**
6925
6932
  * @param {object} args
6926
6933
  * @param {import('../models/FileSystem.js').FileSystem} args.fs
@@ -8462,6 +8469,11 @@ async function applyTreeChanges({
8462
8469
  await fs.rmdir(currentFilepath);
8463
8470
  break
8464
8471
  case 'mkdir':
8472
+ // Don't mkdir through a symlinked leading path: a parent component that
8473
+ // is a symlink could otherwise redirect the directory creation outside
8474
+ // the working tree. git applies the same check (it does not follow
8475
+ // symlinks here) — see checkout.
8476
+ await assertNoSymlinkInLeadingPath(fs, dir, op.filepath);
8465
8477
  await fs.mkdir(currentFilepath);
8466
8478
  break
8467
8479
  case 'rm':
@@ -8474,6 +8486,10 @@ async function applyTreeChanges({
8474
8486
  currentFilepath.startsWith(removedDir)
8475
8487
  )
8476
8488
  ) {
8489
+ // Don't write through a symlinked leading path (see checkout): a
8490
+ // parent component that is a symlink could redirect the write to a
8491
+ // location outside the working tree.
8492
+ await assertNoSymlinkInLeadingPath(fs, dir, op.filepath);
8477
8493
  const { object } = await _readObject({
8478
8494
  fs,
8479
8495
  cache: {},
@@ -9482,8 +9498,8 @@ function filterCapabilities(server, client) {
9482
9498
 
9483
9499
  const pkg = {
9484
9500
  name: 'isomorphic-git',
9485
- version: '1.38.6',
9486
- agent: 'git/isomorphic-git@1.38.6',
9501
+ version: '1.38.8',
9502
+ agent: 'git/isomorphic-git@1.38.8',
9487
9503
  };
9488
9504
 
9489
9505
  class FIFO {
package/index.js CHANGED
@@ -2534,13 +2534,19 @@ function parseBuffer(buffer) {
2534
2534
  // "." and ".." (which resolve outside the working directory), and ".git" (which git
2535
2535
  // disallows as a path component). Checks mirror git's is_ntfs_dotgit() and
2536
2536
  // is_hfs_dotgit(): case-insensitive, trailing dots/spaces stripped (NTFS),
2537
- // NTFS 8.3 short name aliases (git~1..git~9), and HFS+ ignorable Unicode
2538
- // characters stripped (zero-width joiners, directional marks, BOM, etc.).
2537
+ // NTFS 8.3 short name aliases (git~1..git~9), NTFS Alternate Data Streams, and
2538
+ // HFS+ ignorable Unicode characters stripped (zero-width joiners, directional
2539
+ // marks, BOM, etc.).
2539
2540
  const hfsClean = path.replace(
2540
2541
  /[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/g,
2541
2542
  ''
2542
2543
  );
2543
- const normalized = hfsClean.toLowerCase().replace(/[. ]+$/, '');
2544
+ // NTFS Alternate Data Streams are referenced as `<name>:<stream>:<type>`, and a
2545
+ // directory's default stream lets `.git::$INDEX_ALLOCATION` resolve to the `.git`
2546
+ // directory itself. git forbids *any* ADS, so only the portion before the first
2547
+ // colon names the actual entry we normalize and check.
2548
+ const ntfsClean = hfsClean.split(':')[0];
2549
+ const normalized = ntfsClean.toLowerCase().replace(/[. ]+$/, '');
2544
2550
  if (
2545
2551
  path.includes('\\') ||
2546
2552
  path.includes('/') ||
@@ -6871,23 +6877,11 @@ async function branch({
6871
6877
  }
6872
6878
  }
6873
6879
 
6874
- const worthWalking = (filepath, root) => {
6875
- if (filepath === '.' || root == null || root.length === 0 || root === '.') {
6876
- return true
6877
- }
6878
- if (root.length >= filepath.length) {
6879
- return root.startsWith(filepath)
6880
- } else {
6881
- return filepath.startsWith(root)
6882
- }
6883
- };
6884
-
6885
- // @ts-check
6886
-
6887
6880
  /**
6888
- * Throw if any leading directory component of `fullpath` (relative to `dir`) is a symbolic
6889
- * link. git does not follow symlinks in the leading path when writing working-tree files;
6890
- * matching that avoids writing through a symlinked parent into a location outside `dir`.
6881
+ * Refuse to materialize a working-tree entry whose parent path traverses a
6882
+ * symbolic link. A leading component that is a symlink could otherwise redirect
6883
+ * a write or mkdir outside the working tree. git applies the same check: it does
6884
+ * not follow symlinks in the leading path when writing working-tree files.
6891
6885
  *
6892
6886
  * @param {import('../models/FileSystem.js').FileSystem} fs
6893
6887
  * @param {string} dir
@@ -6908,6 +6902,19 @@ async function assertNoSymlinkInLeadingPath(fs, dir, fullpath) {
6908
6902
  }
6909
6903
  }
6910
6904
 
6905
+ const worthWalking = (filepath, root) => {
6906
+ if (filepath === '.' || root == null || root.length === 0 || root === '.') {
6907
+ return true
6908
+ }
6909
+ if (root.length >= filepath.length) {
6910
+ return root.startsWith(filepath)
6911
+ } else {
6912
+ return filepath.startsWith(root)
6913
+ }
6914
+ };
6915
+
6916
+ // @ts-check
6917
+
6911
6918
  /**
6912
6919
  * @param {object} args
6913
6920
  * @param {import('../models/FileSystem.js').FileSystem} args.fs
@@ -8449,6 +8456,11 @@ async function applyTreeChanges({
8449
8456
  await fs.rmdir(currentFilepath);
8450
8457
  break
8451
8458
  case 'mkdir':
8459
+ // Don't mkdir through a symlinked leading path: a parent component that
8460
+ // is a symlink could otherwise redirect the directory creation outside
8461
+ // the working tree. git applies the same check (it does not follow
8462
+ // symlinks here) — see checkout.
8463
+ await assertNoSymlinkInLeadingPath(fs, dir, op.filepath);
8452
8464
  await fs.mkdir(currentFilepath);
8453
8465
  break
8454
8466
  case 'rm':
@@ -8461,6 +8473,10 @@ async function applyTreeChanges({
8461
8473
  currentFilepath.startsWith(removedDir)
8462
8474
  )
8463
8475
  ) {
8476
+ // Don't write through a symlinked leading path (see checkout): a
8477
+ // parent component that is a symlink could redirect the write to a
8478
+ // location outside the working tree.
8479
+ await assertNoSymlinkInLeadingPath(fs, dir, op.filepath);
8464
8480
  const { object } = await _readObject({
8465
8481
  fs,
8466
8482
  cache: {},
@@ -9469,8 +9485,8 @@ function filterCapabilities(server, client) {
9469
9485
 
9470
9486
  const pkg = {
9471
9487
  name: 'isomorphic-git',
9472
- version: '1.38.6',
9473
- agent: 'git/isomorphic-git@1.38.6',
9488
+ version: '1.38.8',
9489
+ agent: 'git/isomorphic-git@1.38.8',
9474
9490
  };
9475
9491
 
9476
9492
  class FIFO {