The tracdelight API does not work as advertised. Even if an image with the extension jpg is requested it might send a png. Although it is sending a correct Content-Type-Header it is not surprising that has not been detected before. Drupal relies on the file extension for determining the mime type and associating the wrong mime type can lead to unexpected results when applying image style effects.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Stefan Freudenberg created an issue. See original summary.

Stefan Freudenberg’s picture

Issue summary: View changes
Stefan Freudenberg’s picture

Title: Images are stored with jpg extension even if trac delight sends a png » Wrong mime type is stored for some images
Issue summary: View changes
Stefan Freudenberg’s picture

The attached patch addresses the above mentioned issue by saving the file with the extension corresponding to the content-type-header sent by tracdelight. It also removes an extraneous content-type-header from the GET request for fetching the images. The content-type-header refers to the entity sent with the request, not the desired format of the response. Please see https://tools.ietf.org/html/rfc2616#section-14.17 and https://tools.ietf.org/html/rfc2616#section-14.1.

Stefan Freudenberg’s picture

Status: Active » Needs review
chr.fritsch’s picture

Status: Needs review » Needs work

Thanks for your work. You are right, we should fetch images independent of its file extension. But what about gifs and bmp or anything else? We should make this generic for all types.

Maybe should just check if content-type starts with 'image/' and the exclude the second part for the file extension?

chr.fritsch’s picture

Status: Needs work » Fixed

Thanks for that patch

drumm’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.