isomorphic-git 1.44.17 → 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/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/index.cjs
CHANGED
|
@@ -2854,6 +2854,60 @@ function mode2type$1(mode) {
|
|
|
2854
2854
|
throw new InternalError(`Unexpected GitTree entry mode: ${mode}`)
|
|
2855
2855
|
}
|
|
2856
2856
|
|
|
2857
|
+
// Drop the trailing dots and spaces of a name, the way Win32 does. A backward
|
|
2858
|
+
// scan, because `/[. ]+$/` costs O(n^2) on a name that is a long run of dots
|
|
2859
|
+
// followed by anything else: the engine retries the run from every start offset,
|
|
2860
|
+
// and an entry name arrives off the wire with no length bound. Only the
|
|
2861
|
+
// reserved-name checks below see this value; the stored path keeps its own
|
|
2862
|
+
// spelling.
|
|
2863
|
+
function stripTrailingDotsAndSpaces(name) {
|
|
2864
|
+
let end = name.length;
|
|
2865
|
+
while (end > 0) {
|
|
2866
|
+
const c = name.charCodeAt(end - 1);
|
|
2867
|
+
if (c !== 46 /* . */ && c !== 32 /* space */) break
|
|
2868
|
+
end--;
|
|
2869
|
+
}
|
|
2870
|
+
return end === name.length ? name : name.slice(0, end)
|
|
2871
|
+
}
|
|
2872
|
+
|
|
2873
|
+
// Reject reserved entry names, matching git's verify_path(): path separators,
|
|
2874
|
+
// "." and ".." (which resolve outside the working directory), and ".git" (which git
|
|
2875
|
+
// disallows as a path component). Checks mirror git's is_ntfs_dotgit() and
|
|
2876
|
+
// is_hfs_dotgit(): case-insensitive, trailing dots/spaces stripped (NTFS),
|
|
2877
|
+
// NTFS 8.3 short name aliases (git~1..git~9), NTFS Alternate Data Streams, and
|
|
2878
|
+
// HFS+ ignorable Unicode characters stripped (zero-width joiners, directional
|
|
2879
|
+
// marks, BOM, etc.).
|
|
2880
|
+
//
|
|
2881
|
+
// Every entry name passes through here, whether it was parsed off the wire or
|
|
2882
|
+
// handed in as an object, so the same tree cannot be written and then refused on
|
|
2883
|
+
// the way back in.
|
|
2884
|
+
function assertSafeEntryPath(path) {
|
|
2885
|
+
const hfsClean = path.replace(
|
|
2886
|
+
/[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/g,
|
|
2887
|
+
''
|
|
2888
|
+
);
|
|
2889
|
+
// NTFS Alternate Data Streams are referenced as `<name>:<stream>:<type>`, and a
|
|
2890
|
+
// directory's default stream lets `.git::$INDEX_ALLOCATION` resolve to the `.git`
|
|
2891
|
+
// directory itself. git forbids *any* ADS, so only the portion before the first
|
|
2892
|
+
// colon names the actual entry we normalize and check.
|
|
2893
|
+
const ntfsClean = hfsClean.split(':')[0];
|
|
2894
|
+
const normalized = stripTrailingDotsAndSpaces(ntfsClean.toLowerCase());
|
|
2895
|
+
// Win32 drops the trailing dots and spaces of a path component, so every name
|
|
2896
|
+
// built only from dots and spaces aliases "." or "..", not just those two exact
|
|
2897
|
+
// spellings: `.. ` resolves to the parent directory. git rejects the whole class
|
|
2898
|
+
// in is_valid_win32_path(). `normalized` is empty for exactly that class, which
|
|
2899
|
+
// is why the test is on it rather than on another trailing-run pattern.
|
|
2900
|
+
if (
|
|
2901
|
+
path.includes('\\') ||
|
|
2902
|
+
path.includes('/') ||
|
|
2903
|
+
(normalized === '' && ntfsClean !== '') ||
|
|
2904
|
+
normalized === '.git' ||
|
|
2905
|
+
/^\.?git~[1-9]$/.test(normalized)
|
|
2906
|
+
) {
|
|
2907
|
+
throw new UnsafeFilepathError(path)
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
|
|
2857
2911
|
function parseBuffer(buffer) {
|
|
2858
2912
|
const _entries = [];
|
|
2859
2913
|
let cursor = 0;
|
|
@@ -2874,34 +2928,7 @@ function parseBuffer(buffer) {
|
|
|
2874
2928
|
if (mode === '40000') mode = '040000'; // makes it line up neater in printed output
|
|
2875
2929
|
const type = mode2type$1(mode);
|
|
2876
2930
|
const path = buffer.slice(space + 1, nullchar).toString('utf8');
|
|
2877
|
-
|
|
2878
|
-
// Reject reserved entry names, matching git's verify_path(): path separators,
|
|
2879
|
-
// "." and ".." (which resolve outside the working directory), and ".git" (which git
|
|
2880
|
-
// disallows as a path component). Checks mirror git's is_ntfs_dotgit() and
|
|
2881
|
-
// is_hfs_dotgit(): case-insensitive, trailing dots/spaces stripped (NTFS),
|
|
2882
|
-
// NTFS 8.3 short name aliases (git~1..git~9), NTFS Alternate Data Streams, and
|
|
2883
|
-
// HFS+ ignorable Unicode characters stripped (zero-width joiners, directional
|
|
2884
|
-
// marks, BOM, etc.).
|
|
2885
|
-
const hfsClean = path.replace(
|
|
2886
|
-
/[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/g,
|
|
2887
|
-
''
|
|
2888
|
-
);
|
|
2889
|
-
// NTFS Alternate Data Streams are referenced as `<name>:<stream>:<type>`, and a
|
|
2890
|
-
// directory's default stream lets `.git::$INDEX_ALLOCATION` resolve to the `.git`
|
|
2891
|
-
// directory itself. git forbids *any* ADS, so only the portion before the first
|
|
2892
|
-
// colon names the actual entry we normalize and check.
|
|
2893
|
-
const ntfsClean = hfsClean.split(':')[0];
|
|
2894
|
-
const normalized = ntfsClean.toLowerCase().replace(/[. ]+$/, '');
|
|
2895
|
-
if (
|
|
2896
|
-
path.includes('\\') ||
|
|
2897
|
-
path.includes('/') ||
|
|
2898
|
-
hfsClean === '.' ||
|
|
2899
|
-
hfsClean === '..' ||
|
|
2900
|
-
normalized === '.git' ||
|
|
2901
|
-
/^\.?git~[1-9]$/.test(normalized)
|
|
2902
|
-
) {
|
|
2903
|
-
throw new UnsafeFilepathError(path)
|
|
2904
|
-
}
|
|
2931
|
+
assertSafeEntryPath(path);
|
|
2905
2932
|
|
|
2906
2933
|
const oid = buffer.slice(nullchar + 1, nullchar + 21).toString('hex');
|
|
2907
2934
|
cursor = nullchar + 21;
|
|
@@ -2931,6 +2958,7 @@ function nudgeIntoShape(entry) {
|
|
|
2931
2958
|
if (!entry.type) {
|
|
2932
2959
|
entry.type = mode2type$1(entry.mode); // index
|
|
2933
2960
|
}
|
|
2961
|
+
assertSafeEntryPath(entry.path);
|
|
2934
2962
|
return entry
|
|
2935
2963
|
}
|
|
2936
2964
|
|
|
@@ -10441,8 +10469,8 @@ function filterCapabilities(server, client) {
|
|
|
10441
10469
|
|
|
10442
10470
|
const pkg = {
|
|
10443
10471
|
name: 'isomorphic-git',
|
|
10444
|
-
version: '1.44.
|
|
10445
|
-
agent: 'git/isomorphic-git@1.44.
|
|
10472
|
+
version: '1.44.18',
|
|
10473
|
+
agent: 'git/isomorphic-git@1.44.18',
|
|
10446
10474
|
};
|
|
10447
10475
|
|
|
10448
10476
|
class FIFO {
|
package/index.js
CHANGED
|
@@ -2848,6 +2848,60 @@ function mode2type$1(mode) {
|
|
|
2848
2848
|
throw new InternalError(`Unexpected GitTree entry mode: ${mode}`)
|
|
2849
2849
|
}
|
|
2850
2850
|
|
|
2851
|
+
// Drop the trailing dots and spaces of a name, the way Win32 does. A backward
|
|
2852
|
+
// scan, because `/[. ]+$/` costs O(n^2) on a name that is a long run of dots
|
|
2853
|
+
// followed by anything else: the engine retries the run from every start offset,
|
|
2854
|
+
// and an entry name arrives off the wire with no length bound. Only the
|
|
2855
|
+
// reserved-name checks below see this value; the stored path keeps its own
|
|
2856
|
+
// spelling.
|
|
2857
|
+
function stripTrailingDotsAndSpaces(name) {
|
|
2858
|
+
let end = name.length;
|
|
2859
|
+
while (end > 0) {
|
|
2860
|
+
const c = name.charCodeAt(end - 1);
|
|
2861
|
+
if (c !== 46 /* . */ && c !== 32 /* space */) break
|
|
2862
|
+
end--;
|
|
2863
|
+
}
|
|
2864
|
+
return end === name.length ? name : name.slice(0, end)
|
|
2865
|
+
}
|
|
2866
|
+
|
|
2867
|
+
// Reject reserved entry names, matching git's verify_path(): path separators,
|
|
2868
|
+
// "." and ".." (which resolve outside the working directory), and ".git" (which git
|
|
2869
|
+
// disallows as a path component). Checks mirror git's is_ntfs_dotgit() and
|
|
2870
|
+
// is_hfs_dotgit(): case-insensitive, trailing dots/spaces stripped (NTFS),
|
|
2871
|
+
// NTFS 8.3 short name aliases (git~1..git~9), NTFS Alternate Data Streams, and
|
|
2872
|
+
// HFS+ ignorable Unicode characters stripped (zero-width joiners, directional
|
|
2873
|
+
// marks, BOM, etc.).
|
|
2874
|
+
//
|
|
2875
|
+
// Every entry name passes through here, whether it was parsed off the wire or
|
|
2876
|
+
// handed in as an object, so the same tree cannot be written and then refused on
|
|
2877
|
+
// the way back in.
|
|
2878
|
+
function assertSafeEntryPath(path) {
|
|
2879
|
+
const hfsClean = path.replace(
|
|
2880
|
+
/[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/g,
|
|
2881
|
+
''
|
|
2882
|
+
);
|
|
2883
|
+
// NTFS Alternate Data Streams are referenced as `<name>:<stream>:<type>`, and a
|
|
2884
|
+
// directory's default stream lets `.git::$INDEX_ALLOCATION` resolve to the `.git`
|
|
2885
|
+
// directory itself. git forbids *any* ADS, so only the portion before the first
|
|
2886
|
+
// colon names the actual entry we normalize and check.
|
|
2887
|
+
const ntfsClean = hfsClean.split(':')[0];
|
|
2888
|
+
const normalized = stripTrailingDotsAndSpaces(ntfsClean.toLowerCase());
|
|
2889
|
+
// Win32 drops the trailing dots and spaces of a path component, so every name
|
|
2890
|
+
// built only from dots and spaces aliases "." or "..", not just those two exact
|
|
2891
|
+
// spellings: `.. ` resolves to the parent directory. git rejects the whole class
|
|
2892
|
+
// in is_valid_win32_path(). `normalized` is empty for exactly that class, which
|
|
2893
|
+
// is why the test is on it rather than on another trailing-run pattern.
|
|
2894
|
+
if (
|
|
2895
|
+
path.includes('\\') ||
|
|
2896
|
+
path.includes('/') ||
|
|
2897
|
+
(normalized === '' && ntfsClean !== '') ||
|
|
2898
|
+
normalized === '.git' ||
|
|
2899
|
+
/^\.?git~[1-9]$/.test(normalized)
|
|
2900
|
+
) {
|
|
2901
|
+
throw new UnsafeFilepathError(path)
|
|
2902
|
+
}
|
|
2903
|
+
}
|
|
2904
|
+
|
|
2851
2905
|
function parseBuffer(buffer) {
|
|
2852
2906
|
const _entries = [];
|
|
2853
2907
|
let cursor = 0;
|
|
@@ -2868,34 +2922,7 @@ function parseBuffer(buffer) {
|
|
|
2868
2922
|
if (mode === '40000') mode = '040000'; // makes it line up neater in printed output
|
|
2869
2923
|
const type = mode2type$1(mode);
|
|
2870
2924
|
const path = buffer.slice(space + 1, nullchar).toString('utf8');
|
|
2871
|
-
|
|
2872
|
-
// Reject reserved entry names, matching git's verify_path(): path separators,
|
|
2873
|
-
// "." and ".." (which resolve outside the working directory), and ".git" (which git
|
|
2874
|
-
// disallows as a path component). Checks mirror git's is_ntfs_dotgit() and
|
|
2875
|
-
// is_hfs_dotgit(): case-insensitive, trailing dots/spaces stripped (NTFS),
|
|
2876
|
-
// NTFS 8.3 short name aliases (git~1..git~9), NTFS Alternate Data Streams, and
|
|
2877
|
-
// HFS+ ignorable Unicode characters stripped (zero-width joiners, directional
|
|
2878
|
-
// marks, BOM, etc.).
|
|
2879
|
-
const hfsClean = path.replace(
|
|
2880
|
-
/[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/g,
|
|
2881
|
-
''
|
|
2882
|
-
);
|
|
2883
|
-
// NTFS Alternate Data Streams are referenced as `<name>:<stream>:<type>`, and a
|
|
2884
|
-
// directory's default stream lets `.git::$INDEX_ALLOCATION` resolve to the `.git`
|
|
2885
|
-
// directory itself. git forbids *any* ADS, so only the portion before the first
|
|
2886
|
-
// colon names the actual entry we normalize and check.
|
|
2887
|
-
const ntfsClean = hfsClean.split(':')[0];
|
|
2888
|
-
const normalized = ntfsClean.toLowerCase().replace(/[. ]+$/, '');
|
|
2889
|
-
if (
|
|
2890
|
-
path.includes('\\') ||
|
|
2891
|
-
path.includes('/') ||
|
|
2892
|
-
hfsClean === '.' ||
|
|
2893
|
-
hfsClean === '..' ||
|
|
2894
|
-
normalized === '.git' ||
|
|
2895
|
-
/^\.?git~[1-9]$/.test(normalized)
|
|
2896
|
-
) {
|
|
2897
|
-
throw new UnsafeFilepathError(path)
|
|
2898
|
-
}
|
|
2925
|
+
assertSafeEntryPath(path);
|
|
2899
2926
|
|
|
2900
2927
|
const oid = buffer.slice(nullchar + 1, nullchar + 21).toString('hex');
|
|
2901
2928
|
cursor = nullchar + 21;
|
|
@@ -2925,6 +2952,7 @@ function nudgeIntoShape(entry) {
|
|
|
2925
2952
|
if (!entry.type) {
|
|
2926
2953
|
entry.type = mode2type$1(entry.mode); // index
|
|
2927
2954
|
}
|
|
2955
|
+
assertSafeEntryPath(entry.path);
|
|
2928
2956
|
return entry
|
|
2929
2957
|
}
|
|
2930
2958
|
|
|
@@ -10429,8 +10457,8 @@ function filterCapabilities(server, client) {
|
|
|
10429
10457
|
|
|
10430
10458
|
const pkg = {
|
|
10431
10459
|
name: 'isomorphic-git',
|
|
10432
|
-
version: '1.44.
|
|
10433
|
-
agent: 'git/isomorphic-git@1.44.
|
|
10460
|
+
version: '1.44.18',
|
|
10461
|
+
agent: 'git/isomorphic-git@1.44.18',
|
|
10434
10462
|
};
|
|
10435
10463
|
|
|
10436
10464
|
class FIFO {
|