Closed benken-parasoft closed 3 months ago
Appears to be a duplicate of ~#394~ (Edit: #135).
Appears to be a duplicate of https://github.com/CycloneDX/cyclonedx-core-java/issues/394
A duplicate of itself? This is a real issue. Copyright and license text can be large with a lot of newlines. BomJsonGenerator strips them out! In contrast, BomXmlGenerator is fine and preserves everything.
Too much copy-pasting. Meant to link to #135.
Too much copy-pasting. Meant to link to https://github.com/CycloneDX/cyclonedx-core-java/issues/135.
Thanks! I'll follow this one instead.
If I serialize a org.cyclonedx.model.Bom to JSON using BomJsonGenerator.toJsonString() then I unexpectedly lose newlines in various strings, like license and copyright text where new lines are especially important.
I tracked down the problem to org.cyclonedx.util.serializer.TrimStringSerializer. This serializer is not just trimming but is also replacing carriage return, line feed, and tab characters with a space. These should be preserved in the JSON. Jackson will correctly escape such characters, like encoding newlines as '\n'.
In contrast, BomXmlGenerator is fine. The XML version has newlines correctly preserved in the XML.
I am currently working around the issue as follows: