Repository: CycloneDX/cyclonedx-core-java
Pull request #502 (2024-09-07 16:16:06)

Fix Issue 385
Fix https://github.com/CycloneDX/cyclonedx-core-java/issues/385


Patch:
diff --git a/src/main/java/org/cyclonedx/util/LicenseResolver.java b/src/main/java/org/cyclonedx/util/LicenseResolver.java
index 1ff24437f..df423d2fb 100644
--- a/src/main/java/org/cyclonedx/util/LicenseResolver.java
+++ b/src/main/java/org/cyclonedx/util/LicenseResolver.java
@@ -200,7 +200,7 @@ public final class LicenseResolver {
             if (is != null) {
                 final String text = IOUtils.toString(is, StandardCharsets.UTF_8);
                 final AttachmentText attachment = new AttachmentText();
-                attachment.setContentType("plain/text");
+                attachment.setContentType("text/plain");
                 switch(licenseTextSettings.getEncoding()){
                     case NONE:
                         attachment.setEncoding(null);


Test patch:
diff --git a/src/test/java/org/cyclonedx/util/LicenseResolverTest.java b/src/test/java/org/cyclonedx/util/LicenseResolverTest.java
index 427a9cca1..f0e8d5168 100644
--- a/src/test/java/org/cyclonedx/util/LicenseResolverTest.java
+++ b/src/test/java/org/cyclonedx/util/LicenseResolverTest.java
@@ -48,7 +48,7 @@ public class LicenseResolverTest {
         assertEquals("GPL-3.0-only", c1.getLicenses().get(0).getId());
         assertEquals("https://www.gnu.org/licenses/gpl-3.0-standalone.html", c1.getLicenses().get(0).getUrl());
         assertNotNull(c1.getLicenses().get(0).getAttachmentText().getText());
-        assertEquals("plain/text", c1.getLicenses().get(0).getAttachmentText().getContentType());
+        assertEquals("text/plain", c1.getLicenses().get(0).getAttachmentText().getContentType());
         assertEquals("base64", c1.getLicenses().get(0).getAttachmentText().getEncoding());
 
         LicenseResolver.LicenseTextSettings textSettings = new LicenseResolver.LicenseTextSettings( true, LicenseResolver.LicenseEncoding.NONE);
@@ -57,7 +57,7 @@ public class LicenseResolverTest {
         assertEquals("GPL-3.0-only", c2.getLicenses().get(0).getId());
         assertEquals("https://www.gnu.org/licenses/gpl-3.0-standalone.html", c2.getLicenses().get(0).getUrl());
         assertNotNull(c2.getLicenses().get(0).getAttachmentText().getText());
-        assertEquals("plain/text", c2.getLicenses().get(0).getAttachmentText().getContentType());
+        assertEquals("text/plain", c2.getLicenses().get(0).getAttachmentText().getContentType());
         assertNull(c2.getLicenses().get(0).getAttachmentText().getEncoding());
 
         textSettings = new LicenseResolver.LicenseTextSettings( true, LicenseResolver.LicenseEncoding.BASE64);
@@ -66,7 +66,7 @@ public class LicenseResolverTest {
         assertEquals("GPL-3.0-only", c3.getLicenses().get(0).getId());
         assertEquals("https://www.gnu.org/licenses/gpl-3.0-standalone.html", c3.getLicenses().get(0).getUrl());
         assertNotNull(c3.getLicenses().get(0).getAttachmentText().getText());
-        assertEquals("plain/text", c3.getLicenses().get(0).getAttachmentText().getContentType());
+        assertEquals("text/plain", c3.getLicenses().get(0).getAttachmentText().getContentType());
         assertEquals("base64", c3.getLicenses().get(0).getAttachmentText().getEncoding());
     }