isomorphic-git 1.44.16 → 1.44.18
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/http/node/index.cjs +102 -26
- package/http/node/index.d.cts +8 -0
- package/http/node/index.d.ts +8 -0
- package/http/node/index.js +102 -26
- package/index.cjs +58 -30
- package/index.js +58 -30
- package/index.umd.min.js +1 -1
- package/index.umd.min.js.map +1 -1
- package/managers/index.cjs +56 -28
- package/managers/index.js +56 -28
- package/package.json +1 -1
package/managers/index.cjs
CHANGED
|
@@ -5439,6 +5439,60 @@ function mode2type$1(mode) {
|
|
|
5439
5439
|
throw new InternalError(`Unexpected GitTree entry mode: ${mode}`)
|
|
5440
5440
|
}
|
|
5441
5441
|
|
|
5442
|
+
// Drop the trailing dots and spaces of a name, the way Win32 does. A backward
|
|
5443
|
+
// scan, because `/[. ]+$/` costs O(n^2) on a name that is a long run of dots
|
|
5444
|
+
// followed by anything else: the engine retries the run from every start offset,
|
|
5445
|
+
// and an entry name arrives off the wire with no length bound. Only the
|
|
5446
|
+
// reserved-name checks below see this value; the stored path keeps its own
|
|
5447
|
+
// spelling.
|
|
5448
|
+
function stripTrailingDotsAndSpaces(name) {
|
|
5449
|
+
let end = name.length;
|
|
5450
|
+
while (end > 0) {
|
|
5451
|
+
const c = name.charCodeAt(end - 1);
|
|
5452
|
+
if (c !== 46 /* . */ && c !== 32 /* space */) break
|
|
5453
|
+
end--;
|
|
5454
|
+
}
|
|
5455
|
+
return end === name.length ? name : name.slice(0, end)
|
|
5456
|
+
}
|
|
5457
|
+
|
|
5458
|
+
// Reject reserved entry names, matching git's verify_path(): path separators,
|
|
5459
|
+
// "." and ".." (which resolve outside the working directory), and ".git" (which git
|
|
5460
|
+
// disallows as a path component). Checks mirror git's is_ntfs_dotgit() and
|
|
5461
|
+
// is_hfs_dotgit(): case-insensitive, trailing dots/spaces stripped (NTFS),
|
|
5462
|
+
// NTFS 8.3 short name aliases (git~1..git~9), NTFS Alternate Data Streams, and
|
|
5463
|
+
// HFS+ ignorable Unicode characters stripped (zero-width joiners, directional
|
|
5464
|
+
// marks, BOM, etc.).
|
|
5465
|
+
//
|
|
5466
|
+
// Every entry name passes through here, whether it was parsed off the wire or
|
|
5467
|
+
// handed in as an object, so the same tree cannot be written and then refused on
|
|
5468
|
+
// the way back in.
|
|
5469
|
+
function assertSafeEntryPath(path) {
|
|
5470
|
+
const hfsClean = path.replace(
|
|
5471
|
+
/[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/g,
|
|
5472
|
+
''
|
|
5473
|
+
);
|
|
5474
|
+
// NTFS Alternate Data Streams are referenced as `<name>:<stream>:<type>`, and a
|
|
5475
|
+
// directory's default stream lets `.git::$INDEX_ALLOCATION` resolve to the `.git`
|
|
5476
|
+
// directory itself. git forbids *any* ADS, so only the portion before the first
|
|
5477
|
+
// colon names the actual entry we normalize and check.
|
|
5478
|
+
const ntfsClean = hfsClean.split(':')[0];
|
|
5479
|
+
const normalized = stripTrailingDotsAndSpaces(ntfsClean.toLowerCase());
|
|
5480
|
+
// Win32 drops the trailing dots and spaces of a path component, so every name
|
|
5481
|
+
// built only from dots and spaces aliases "." or "..", not just those two exact
|
|
5482
|
+
// spellings: `.. ` resolves to the parent directory. git rejects the whole class
|
|
5483
|
+
// in is_valid_win32_path(). `normalized` is empty for exactly that class, which
|
|
5484
|
+
// is why the test is on it rather than on another trailing-run pattern.
|
|
5485
|
+
if (
|
|
5486
|
+
path.includes('\\') ||
|
|
5487
|
+
path.includes('/') ||
|
|
5488
|
+
(normalized === '' && ntfsClean !== '') ||
|
|
5489
|
+
normalized === '.git' ||
|
|
5490
|
+
/^\.?git~[1-9]$/.test(normalized)
|
|
5491
|
+
) {
|
|
5492
|
+
throw new UnsafeFilepathError(path)
|
|
5493
|
+
}
|
|
5494
|
+
}
|
|
5495
|
+
|
|
5442
5496
|
function parseBuffer(buffer) {
|
|
5443
5497
|
const _entries = [];
|
|
5444
5498
|
let cursor = 0;
|
|
@@ -5459,34 +5513,7 @@ function parseBuffer(buffer) {
|
|
|
5459
5513
|
if (mode === '40000') mode = '040000'; // makes it line up neater in printed output
|
|
5460
5514
|
const type = mode2type$1(mode);
|
|
5461
5515
|
const path = buffer.slice(space + 1, nullchar).toString('utf8');
|
|
5462
|
-
|
|
5463
|
-
// Reject reserved entry names, matching git's verify_path(): path separators,
|
|
5464
|
-
// "." and ".." (which resolve outside the working directory), and ".git" (which git
|
|
5465
|
-
// disallows as a path component). Checks mirror git's is_ntfs_dotgit() and
|
|
5466
|
-
// is_hfs_dotgit(): case-insensitive, trailing dots/spaces stripped (NTFS),
|
|
5467
|
-
// NTFS 8.3 short name aliases (git~1..git~9), NTFS Alternate Data Streams, and
|
|
5468
|
-
// HFS+ ignorable Unicode characters stripped (zero-width joiners, directional
|
|
5469
|
-
// marks, BOM, etc.).
|
|
5470
|
-
const hfsClean = path.replace(
|
|
5471
|
-
/[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/g,
|
|
5472
|
-
''
|
|
5473
|
-
);
|
|
5474
|
-
// NTFS Alternate Data Streams are referenced as `<name>:<stream>:<type>`, and a
|
|
5475
|
-
// directory's default stream lets `.git::$INDEX_ALLOCATION` resolve to the `.git`
|
|
5476
|
-
// directory itself. git forbids *any* ADS, so only the portion before the first
|
|
5477
|
-
// colon names the actual entry we normalize and check.
|
|
5478
|
-
const ntfsClean = hfsClean.split(':')[0];
|
|
5479
|
-
const normalized = ntfsClean.toLowerCase().replace(/[. ]+$/, '');
|
|
5480
|
-
if (
|
|
5481
|
-
path.includes('\\') ||
|
|
5482
|
-
path.includes('/') ||
|
|
5483
|
-
hfsClean === '.' ||
|
|
5484
|
-
hfsClean === '..' ||
|
|
5485
|
-
normalized === '.git' ||
|
|
5486
|
-
/^\.?git~[1-9]$/.test(normalized)
|
|
5487
|
-
) {
|
|
5488
|
-
throw new UnsafeFilepathError(path)
|
|
5489
|
-
}
|
|
5516
|
+
assertSafeEntryPath(path);
|
|
5490
5517
|
|
|
5491
5518
|
const oid = buffer.slice(nullchar + 1, nullchar + 21).toString('hex');
|
|
5492
5519
|
cursor = nullchar + 21;
|
|
@@ -5516,6 +5543,7 @@ function nudgeIntoShape(entry) {
|
|
|
5516
5543
|
if (!entry.type) {
|
|
5517
5544
|
entry.type = mode2type$1(entry.mode); // index
|
|
5518
5545
|
}
|
|
5546
|
+
assertSafeEntryPath(entry.path);
|
|
5519
5547
|
return entry
|
|
5520
5548
|
}
|
|
5521
5549
|
|
package/managers/index.js
CHANGED
|
@@ -5427,6 +5427,60 @@ function mode2type$1(mode) {
|
|
|
5427
5427
|
throw new InternalError(`Unexpected GitTree entry mode: ${mode}`)
|
|
5428
5428
|
}
|
|
5429
5429
|
|
|
5430
|
+
// Drop the trailing dots and spaces of a name, the way Win32 does. A backward
|
|
5431
|
+
// scan, because `/[. ]+$/` costs O(n^2) on a name that is a long run of dots
|
|
5432
|
+
// followed by anything else: the engine retries the run from every start offset,
|
|
5433
|
+
// and an entry name arrives off the wire with no length bound. Only the
|
|
5434
|
+
// reserved-name checks below see this value; the stored path keeps its own
|
|
5435
|
+
// spelling.
|
|
5436
|
+
function stripTrailingDotsAndSpaces(name) {
|
|
5437
|
+
let end = name.length;
|
|
5438
|
+
while (end > 0) {
|
|
5439
|
+
const c = name.charCodeAt(end - 1);
|
|
5440
|
+
if (c !== 46 /* . */ && c !== 32 /* space */) break
|
|
5441
|
+
end--;
|
|
5442
|
+
}
|
|
5443
|
+
return end === name.length ? name : name.slice(0, end)
|
|
5444
|
+
}
|
|
5445
|
+
|
|
5446
|
+
// Reject reserved entry names, matching git's verify_path(): path separators,
|
|
5447
|
+
// "." and ".." (which resolve outside the working directory), and ".git" (which git
|
|
5448
|
+
// disallows as a path component). Checks mirror git's is_ntfs_dotgit() and
|
|
5449
|
+
// is_hfs_dotgit(): case-insensitive, trailing dots/spaces stripped (NTFS),
|
|
5450
|
+
// NTFS 8.3 short name aliases (git~1..git~9), NTFS Alternate Data Streams, and
|
|
5451
|
+
// HFS+ ignorable Unicode characters stripped (zero-width joiners, directional
|
|
5452
|
+
// marks, BOM, etc.).
|
|
5453
|
+
//
|
|
5454
|
+
// Every entry name passes through here, whether it was parsed off the wire or
|
|
5455
|
+
// handed in as an object, so the same tree cannot be written and then refused on
|
|
5456
|
+
// the way back in.
|
|
5457
|
+
function assertSafeEntryPath(path) {
|
|
5458
|
+
const hfsClean = path.replace(
|
|
5459
|
+
/[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/g,
|
|
5460
|
+
''
|
|
5461
|
+
);
|
|
5462
|
+
// NTFS Alternate Data Streams are referenced as `<name>:<stream>:<type>`, and a
|
|
5463
|
+
// directory's default stream lets `.git::$INDEX_ALLOCATION` resolve to the `.git`
|
|
5464
|
+
// directory itself. git forbids *any* ADS, so only the portion before the first
|
|
5465
|
+
// colon names the actual entry we normalize and check.
|
|
5466
|
+
const ntfsClean = hfsClean.split(':')[0];
|
|
5467
|
+
const normalized = stripTrailingDotsAndSpaces(ntfsClean.toLowerCase());
|
|
5468
|
+
// Win32 drops the trailing dots and spaces of a path component, so every name
|
|
5469
|
+
// built only from dots and spaces aliases "." or "..", not just those two exact
|
|
5470
|
+
// spellings: `.. ` resolves to the parent directory. git rejects the whole class
|
|
5471
|
+
// in is_valid_win32_path(). `normalized` is empty for exactly that class, which
|
|
5472
|
+
// is why the test is on it rather than on another trailing-run pattern.
|
|
5473
|
+
if (
|
|
5474
|
+
path.includes('\\') ||
|
|
5475
|
+
path.includes('/') ||
|
|
5476
|
+
(normalized === '' && ntfsClean !== '') ||
|
|
5477
|
+
normalized === '.git' ||
|
|
5478
|
+
/^\.?git~[1-9]$/.test(normalized)
|
|
5479
|
+
) {
|
|
5480
|
+
throw new UnsafeFilepathError(path)
|
|
5481
|
+
}
|
|
5482
|
+
}
|
|
5483
|
+
|
|
5430
5484
|
function parseBuffer(buffer) {
|
|
5431
5485
|
const _entries = [];
|
|
5432
5486
|
let cursor = 0;
|
|
@@ -5447,34 +5501,7 @@ function parseBuffer(buffer) {
|
|
|
5447
5501
|
if (mode === '40000') mode = '040000'; // makes it line up neater in printed output
|
|
5448
5502
|
const type = mode2type$1(mode);
|
|
5449
5503
|
const path = buffer.slice(space + 1, nullchar).toString('utf8');
|
|
5450
|
-
|
|
5451
|
-
// Reject reserved entry names, matching git's verify_path(): path separators,
|
|
5452
|
-
// "." and ".." (which resolve outside the working directory), and ".git" (which git
|
|
5453
|
-
// disallows as a path component). Checks mirror git's is_ntfs_dotgit() and
|
|
5454
|
-
// is_hfs_dotgit(): case-insensitive, trailing dots/spaces stripped (NTFS),
|
|
5455
|
-
// NTFS 8.3 short name aliases (git~1..git~9), NTFS Alternate Data Streams, and
|
|
5456
|
-
// HFS+ ignorable Unicode characters stripped (zero-width joiners, directional
|
|
5457
|
-
// marks, BOM, etc.).
|
|
5458
|
-
const hfsClean = path.replace(
|
|
5459
|
-
/[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/g,
|
|
5460
|
-
''
|
|
5461
|
-
);
|
|
5462
|
-
// NTFS Alternate Data Streams are referenced as `<name>:<stream>:<type>`, and a
|
|
5463
|
-
// directory's default stream lets `.git::$INDEX_ALLOCATION` resolve to the `.git`
|
|
5464
|
-
// directory itself. git forbids *any* ADS, so only the portion before the first
|
|
5465
|
-
// colon names the actual entry we normalize and check.
|
|
5466
|
-
const ntfsClean = hfsClean.split(':')[0];
|
|
5467
|
-
const normalized = ntfsClean.toLowerCase().replace(/[. ]+$/, '');
|
|
5468
|
-
if (
|
|
5469
|
-
path.includes('\\') ||
|
|
5470
|
-
path.includes('/') ||
|
|
5471
|
-
hfsClean === '.' ||
|
|
5472
|
-
hfsClean === '..' ||
|
|
5473
|
-
normalized === '.git' ||
|
|
5474
|
-
/^\.?git~[1-9]$/.test(normalized)
|
|
5475
|
-
) {
|
|
5476
|
-
throw new UnsafeFilepathError(path)
|
|
5477
|
-
}
|
|
5504
|
+
assertSafeEntryPath(path);
|
|
5478
5505
|
|
|
5479
5506
|
const oid = buffer.slice(nullchar + 1, nullchar + 21).toString('hex');
|
|
5480
5507
|
cursor = nullchar + 21;
|
|
@@ -5504,6 +5531,7 @@ function nudgeIntoShape(entry) {
|
|
|
5504
5531
|
if (!entry.type) {
|
|
5505
5532
|
entry.type = mode2type$1(entry.mode); // index
|
|
5506
5533
|
}
|
|
5534
|
+
assertSafeEntryPath(entry.path);
|
|
5507
5535
|
return entry
|
|
5508
5536
|
}
|
|
5509
5537
|
|