snyk 1.792.0 → 1.793.0
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/dist/cli/64.index.js
CHANGED
|
@@ -207822,12 +207822,16 @@ async function loadNuspecFromAsync(dep) {
|
|
|
207822
207822
|
if (!nuspecZipData) {
|
|
207823
207823
|
throw new Error(`failed to open nupkg file as an archive from: ${nupkgPath}`);
|
|
207824
207824
|
}
|
|
207825
|
-
|
|
207825
|
+
const rawNuspecContent = await nuspecZipData.files[nuspecFile].async('text');
|
|
207826
|
+
const encoding = detectNuspecContentEncoding(rawNuspecContent);
|
|
207827
|
+
const encodedNuspecContent = Buffer.from(rawNuspecContent).toString(encoding);
|
|
207828
|
+
const normalisedNuspecContent = removePotentialUtf16Characters(encodedNuspecContent);
|
|
207829
|
+
return normalisedNuspecContent;
|
|
207826
207830
|
}
|
|
207827
207831
|
//this is exported for testing, but should not executed directly. Hence the '_' in the name.
|
|
207828
207832
|
async function _parsedNuspec(nuspecContent, targetFramework, depName) {
|
|
207829
207833
|
var _a;
|
|
207830
|
-
const parsedNuspec = await parseXML.parseStringPromise(nuspecContent
|
|
207834
|
+
const parsedNuspec = await parseXML.parseStringPromise(nuspecContent);
|
|
207831
207835
|
let ownDeps = [];
|
|
207832
207836
|
//note: this will throw if assertion fails
|
|
207833
207837
|
assertNuspecSchema(parsedNuspec);
|
|
@@ -207942,6 +207946,26 @@ function extractDepsFromRaw(rawDependencies) {
|
|
|
207942
207946
|
});
|
|
207943
207947
|
return deps;
|
|
207944
207948
|
}
|
|
207949
|
+
var SupportedEncodings;
|
|
207950
|
+
(function (SupportedEncodings) {
|
|
207951
|
+
SupportedEncodings["UTF8"] = "utf-8";
|
|
207952
|
+
SupportedEncodings["UTF16LE"] = "utf-16le";
|
|
207953
|
+
})(SupportedEncodings || (SupportedEncodings = {}));
|
|
207954
|
+
function detectNuspecContentEncoding(nuspecContent) {
|
|
207955
|
+
// 65533 is a code for replacement character that is unique to UTF-16
|
|
207956
|
+
// https://www.unicodepedia.com/unicode/specials/fffd/replacement-character/
|
|
207957
|
+
if (nuspecContent.charCodeAt(0) === 65533) {
|
|
207958
|
+
return SupportedEncodings.UTF16LE;
|
|
207959
|
+
}
|
|
207960
|
+
return SupportedEncodings.UTF8;
|
|
207961
|
+
}
|
|
207962
|
+
function removePotentialUtf16Characters(input) {
|
|
207963
|
+
return input
|
|
207964
|
+
.replace(/\uFFFD/g, '')
|
|
207965
|
+
.replace(/\uBFEF/g, '')
|
|
207966
|
+
.replace(/\uBDBF/g, '')
|
|
207967
|
+
.replace(/\uEFBD/g, '');
|
|
207968
|
+
}
|
|
207945
207969
|
//# sourceMappingURL=nuspec-parser.js.map
|
|
207946
207970
|
|
|
207947
207971
|
/***/ }),
|