Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
When guessing MIME type for files stored in remote file systems, for example dummy-remote://test.png
,MIME type returned is always application/octet-stream
.
That's because MimeTypeGuesser::guess
always try to replace the $path passed in with its realpath.
But remote stream wrapper return NULL for ->realpath()
, hence the default MIME type applies.
Proposed resolution
Replace the $path only if a sensible realpath is returned by the wrapper.
Remaining tasks
review
User interface changes
none
API changes
none
Data model changes
none
Comment | File | Size | Author |
---|---|---|---|
#5 | 2760797-5.patch | 2.28 KB | mondrake |
#5 | interdiff_2-5.txt | 697 bytes | mondrake |
#2 | 2760797-2.diff | 2.25 KB | mondrake |
#2 | 2760797-2-test-only.diff | 1.43 KB | mondrake |
Comments
Comment #2
mondrakePatch
Comment #4
twistor CreditAttribution: twistor as a volunteer commentedThis should check !== FASLE, since realpath() could return '0'.
According to
StreamWrapperInterface::realpath()
, it should return FALSE, not NULL if unsupported.Comment #5
mondrakeThank you @twistor. Done #4.
Comment #6
twistor CreditAttribution: twistor as a volunteer commentedComment #7
alexpottCommitted and pushed 4e547f5246e09ad41ce5caba8ead3bf4a7baec59 to 8.2.x and 3de9785 to 8.1.x. Thanks!
Nice find and fix. Committing to both branches as the bug fix is patch eligible.