Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEXUS-29524] Fixes DMG files upload to Raw Repo with content type validation ON #92

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<String> 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)
Expand Down