Fix detecting text/x-php mimetype and secure mimetype mapping #22646
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.
Steps to reproduce
text/x-php
instead ofapplication/x-php
as a mimetype for php filesBefore:
The mimetype was always detected as application/octet-stream as
text/x-php
was never part of the secure mime type list.After:
text/x-php
is a valid mimetype to be returned bydetectContent
. Now this PR is however kind of a hack since we abuse the secure mime fallback to actually also detect changes there. Ideally this would be an individual entry in https://github.com/nextcloud/server/blob/16b981735895424dd2d59707af87716c0e04d363/resources/config/mimetypemapping.dist.json but there is no way to extend the json without breaking changes since it still uses the file extension as a key for the entries. Also having both the secure and insecure mapping to the secure mimetype seems to be more sane than just the insecure mapping.Proposal
For a breaking change we could pull out the insecure->secure mimetype mapping to a separate file and just use mimetypemapping.dist.json for a list of all trusted mimetypes. mimetypealiases.json will not fit for this since it is only for mapping to simplified filetypes which are used for icons, so all code files e.g. will be "text/code"