fix(artifacts): apply XML end-of-line handling to nuspec and POM text (#11846)

The .nuspec, its OPC relationships and the Maven POM now parse with
lineEndings normalize, as XML 1.0 section 2.11 and the NuGet and Maven
readers do. Text from CRLF files no longer keeps carriage returns.
This commit is contained in:
RRFZ
2026-11-18 08:48:57 -05:00
committed by GitHub
parent da5ff5e7a7
commit 372e6e2fa0
6 changed files with 42 additions and 5 deletions
@@ -415,6 +415,19 @@ it("removes credentials from POM property values", () => {
expect(JSON.stringify(report)).not.toContain("password");
});
it("applies XML end-of-line handling to POM text", () => {
const report = parse(
"<project>\r\n <modelVersion>4.0.0</modelVersion>\r\n <artifactId>demo</artifactId>\r\n <properties>\r\n <banner>first\r\nsecond\rthird</banner>\r\n </properties>\r\n</project>\r\n",
);
expect(report.properties).toEqual([
{
name: "banner",
value: "first\nsecond\nthird",
value_credentials_redacted: false,
},
]);
});
it("lists properties in packaging, scope, type and classifier", () => {
const report = parse(`<project>
<groupId>com.example</groupId>
+3 -1
View File
@@ -272,9 +272,11 @@ const parsePom = (
MAVEN_GRADLE_METADATA_XML_NODES,
nodes,
);
// Maven's XML reader applies XML 1.0 end-of-line handling, so a POM saved
// with CRLF yields the same property and coordinate text as one with LF.
const parsed = parseXmlDocument(xml, {
doctype: "reject",
lineEndings: "preserve",
lineEndings: "normalize",
});
if (!parsed.ok)
throw parsed.error.kind === "unsupported"