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.
The Content-Type header set by file_get_content_headers()
adds a name attribute, that isn't standard or documented anywhere on the Internet. Although it doesn't cause any problems, leaving it in might confuse people (like me) when looking for bugs in their code.
I'll add a patch to remove it from Drupal 8. I'll be happy to port it to Drupal 7 and perhaps 6 if needed.
Comment | File | Size | Author |
---|---|---|---|
#4 | remove-content-type-name-attr-1773032-1-d7.patch | 1.76 KB | Jorrit |
#1 | remove-content-type-name-attr-1773032-1.patch | 2.04 KB | Jorrit |
Comments
Comment #1
Jorrit CreditAttribution: Jorrit commentedThe patch.
Comment #2
quicksketchI researched this yesterday and came up with the following conclusions in an e-mail to Jorrit:
TL;DR: We already fixed this in core once, but the FileField port into D7 reintroduced the problem. See http://drupal.org/node/103164.
Comment #3
webchickLOL that's awesome. Awesome find Jorrit, and awesome sleuthing too, quicksketch!
Committed and pushed to 8.x. We should fix this in 7.x, too.
Comment #4
Jorrit CreditAttribution: Jorrit commentedHere you go. Thanks for the quick commit!
Comment #5
dcam CreditAttribution: dcam commentedI'm not certain how to test this one since the bug isn't causing a problem for me with any browser that I've tried (using a private file field in FF, Chrome, and IE9). It's basically the same patch that got committed to D8 and the same fix that was introduced in #103164: Internet Explorer Not Opening Attachments Correctly-double window issue. The patch applied correctly and file downloads continued to work afterward. So I'm marking it RTBC. If anyone thinks this should be tested more thoroughly, go ahead and set the status back to "Needs review."
Comment #6
David_Rothstein CreditAttribution: David_Rothstein commentedWow, with a history like that it is almost sad to remove it :) Like, it's been through so much, it doesn't deserve to die. Or maybe we are tempting fate, and it will be back again later, only this time more powerful than before...
Anyway, it seems to me like it's been tested and reviewed well enough, so I committed this to 7.x - thanks! http://drupalcode.org/project/drupal.git/commit/e218eff
As far as I can tell from reading the issue, there actually isn't anything to fix in Drupal 6 here, but feel free to reopen and backport if I'm wrong.
Comment #7
David_Rothstein CreditAttribution: David_Rothstein commentedOh by the way, I did a little Googling and I got the impression that maybe this attribute once did exist, but was deprecated sometime in the early 1990's :)
http://www.imc.org/ietf-822/old-archive2/msg02121.html
Though I wasn't 100% sure that was referring to the same thing.
Comment #9
David_Rothstein CreditAttribution: David_Rothstein commentedAlthough this is a pretty trivial change, it did break a core test, so on second thought I'm adding this to the release notes and CHANGELOG.txt just in case someone is relying on it somewhere.
Comment #10
neRok CreditAttribution: neRok commentedJust found the following related issue where it has been found the 'name' part of the return array should have been called 'filename'.
#2010360: file_get_content_headers should add a Content-Disposition header with "filename" in it