Skip content type filters where possible. #2464
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prior to this patch every content_type_* filter would parse magic headers via
SanitizedFile#content_type
,even when the filter was not defined.
I have split the primary conditional check in to a guard clause that
simply returns unless the blacklist or whitelist returns truthy.
I've made the same changes to the extension filters for consistency.
I wanted to remove any unnecessary parse of magic headers completely on upload. This is a half measure to getting there.