No charset on response for patch & text files

Created on 10 November 2017, over 7 years ago
Updated 16 May 2025, 21 days ago

I just noticed that on drupal.org, .patch files are being served up using content encoding Windows-1252. This is a problem because if you include UTF-8 characters in your patch they will be displayed incorrectly.

Actually, it may just be that no encoding is being set by the server, and the browser just assumes Windows-1252 for some reason, but I see this on Chrome/Firefox on a Linux machine, and on Edge with a Windows machine, so it's consistent.

You can look at any patch file on drupal.org and check the page info in the browser to see this.
But most patch files don't have UTF-8 characters, so they look fine.

For example of a patch that contains UTF-8, take a look at:

https://www.drupal.org/node/2879270#comment-12337440
and click on
https://www.drupal.org/files/issues/usps_first_class-2879270-5.patch

It will display mangled, like this:

diff --git a/shipping/uc_usps/uc_usps.module b/shipping/uc_usps/uc_usps.module
index 8a18b1b..dffacb3 100644
--- a/shipping/uc_usps/uc_usps.module
+++ b/shipping/uc_usps/uc_usps.module
@@ -370,7 +370,7 @@ function uc_usps_quote($products, $details, $method) {
             foreach ($package->Postage as $postage) {
               $classid = (string)$postage['CLASSID'];
               if ($classid === '0') {
-                if ((string)$postage->MailService == "First-Class Mail® Parcel") {
+                if ((string)$postage->MailService == "First-Class Package Service - Retailâ„¢") {
                   $classid = 'zeroParcel';
                 }
                 elseif ((string)$postage->MailService == "First-Class Mail® Letter") {

See how the trademark symbols have odd characters next to them?
If you use wget to download this patch it looks fine - it's only the display in the browser that's wrong.

I suggest forcing the encoding to UTF-8 by sending text/plain with Content-Type: text/plain; charset=utf-8.

🐛 Bug report
Status

Active

Component

Servers

Created by

🇺🇸United States tr Cascadia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States tr Cascadia

    This is still a problem, albeit less important now that we've switched to MRs. However, file attachments are still used in the issue queues, and this bug still affects those.

    This needs to be fixed in the drupal.org server configuration. The specific way to fix it depends on the specifics of how the drupal.org servers are set up, which I know nothing about.

Production build 0.71.5 2024