From a5c30e4fbd1893198506b6b79c023817bd073322 Mon Sep 17 00:00:00 2001 From: Tetiana Tvardovska Date: Fri, 12 Nov 2021 20:11:41 +0200 Subject: [PATCH] NEXUS-29524 Fixes upload for OCX DMG files to Nexus Repo Raw Repository with content type validation ON --- .../nexus/repository/mime/DefaultContentValidator.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/nexus-repository-services/src/main/java/org/sonatype/nexus/repository/mime/DefaultContentValidator.java b/components/nexus-repository-services/src/main/java/org/sonatype/nexus/repository/mime/DefaultContentValidator.java index faa5985ce6..086b4b153a 100644 --- a/components/nexus-repository-services/src/main/java/org/sonatype/nexus/repository/mime/DefaultContentValidator.java +++ b/components/nexus-repository-services/src/main/java/org/sonatype/nexus/repository/mime/DefaultContentValidator.java @@ -72,7 +72,7 @@ public String determineContentType(final boolean strictContentTypeValidation, contentDetectedMimeTypes.addAll(mimeSupport.detectMimeTypes(is, contentName)); } adjustIfHtml(contentDetectedMimeTypes); - log.debug("Mime support detects {} as {}", contentName, contentDetectedMimeTypes); + log.info("Mime support detects {} as {}", contentName, contentDetectedMimeTypes); if (strictContentTypeValidation && isUnknown(contentDetectedMimeTypes)) { throw new InvalidContentException("Content type could not be determined: " + contentName); @@ -86,12 +86,16 @@ public String determineContentType(final boolean strictContentTypeValidation, mimeRulesSource != null ? mimeRulesSource : MimeRulesSource.NOOP) ); adjustIfHtml(nameAssumedMimeTypes); - log.debug("Mime support assumes {} as {}", contentName, nameAssumedMimeTypes); + log.info("Mime support assumes {} as {} {}", contentName, nameAssumedMimeTypes); if (!isUnknown(nameAssumedMimeTypes)) { Set intersection = Sets.intersection(contentDetectedMimeTypes, nameAssumedMimeTypes); log.debug("content/name types intersection {}", intersection); - if (strictContentTypeValidation && intersection.isEmpty()) { + if ( strictContentTypeValidation && intersection.isEmpty() + && !("[application/x-apple-diskimage]".equals(nameAssumedMimeTypes.toString()) + && ( "[application/x-bzip]".equals(contentDetectedMimeTypes.toString()) + || "[application/zlib]".equals(contentDetectedMimeTypes.toString())) ) + ) { throw new InvalidContentException( String.format("Detected content type %s, but expected %s: %s", contentDetectedMimeTypes, nameAssumedMimeTypes, contentName)