Page MenuHomePhabricator

Serve mediawiki keys.txt with UTF-8 charset
Closed, ResolvedPublicPRODUCTION ERROR

Description

https://www.mediawiki.org/keys/keys.txt used to be an ASCII-only file; since the addition of Bartosz Dziewoński it is (and will presumably remain for all eternity) a UTF-8 file. However, we currently serve it with a simple Content-Type: text/plain header; as a result, a browser displaying the file may guess the wrong encoding and mangle the name:

The PGP key name shows up as Bartosz Dziewoński

We should probably serve it with Content-Type: text/plain; charset=utf-8.

Event Timeline

(I don’t know which tags to add to this task :/ and I also don’t know where to fix this. The overall mediawiki.org docroot seems to be configured in hieradata/common/mediawiki.yaml, but I don’t know how to change any headers there.)

I think charset=utf-8 would be correct not just for keys.txt, but also for all .txt files, and possibly for all files in general. That could be configured by adding, respectively, AddCharset UTF-8 .txt [other uses] or AddDefaultCharset UTF-8 [other uses] (docs), either in mediawiki-vhost.conf.erb (for all wikis) or in additional_rewrites for www.mediawiki.org. Configuring it just for that one file would be a bit more fiddly.

There are only a few other .txt files served like this, e.g. https://www.mediawiki.org/.well-known/security.txt and https://auth.wikimedia.org/robots.txt. (robots.txt on other domains are already served with charset=utf-8, because they are handled by the robots.php script; likewise for any files from MediaWiki, handled by static.php.)

Restricted Application changed the subtype of this task from "Task" to "Production Error". · View Herald TranscriptThu, Jun 11, 8:51 AM

Change #1300713 had a related patch set uploaded (by Blake; author: Blake):

[operations/puppet@production] mediawiki::web::vhost: Use utf-8 for text/plain and text/html.

https://gerrit.wikimedia.org/r/1300713

Change #1300713 merged by Blake:

[operations/puppet@production] mediawiki::web::vhost: Use utf-8 for text/plain and text/html.

https://gerrit.wikimedia.org/r/1300713

Mentioned in SAL (#wikimedia-operations) [2026-06-11T17:20:02Z] <blake@deploy1003> Started scap sync-world: apache config update (T428772)

Mentioned in SAL (#wikimedia-operations) [2026-06-11T17:20:53Z] <blake@deploy1003> blake: apache config update (T428772) synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Looks like my patch didn't work - the charset parameter wasn't added to the Content-Type header. I'm currently in the process of reverting, and will explore this more tomorrow.

When making changes to keys.txt the other day, we had to manually purge the cache for that page using purgeList – see SAL entry. Maybe that was also needed here?

When making changes to keys.txt the other day, we had to manually purge the cache for that page using purgeList – see SAL entry. Maybe that was also needed here?

I wasn't following closely as @Blake rolled this out, but it looked like we reverted because the httpbb test failed. If so, purgeList won't be a factor: httpbb tests bypass the CDN and exercise the MW pod directly.

But after that's resolved and this is fully deployed at the app layer, purging the CDN cache is separately a good idea to make sure it's externally visible.

I'm inclined to try adding .txt to the UTF-8 AddCharset directive here, unless anyone else has a more informed opinion about how to proceed.

Change #1301338 had a related patch set uploaded (by Blake; author: Blake):

[operations/puppet@production] mediawiki: Use utf-8 for text/plain and text/html.

https://gerrit.wikimedia.org/r/1301338

After a spelunking session with @Clement_Goubert (thanks very much!), we found that Apache configuration for mw-on-k8s ought to be modified in hieradata/common/mediawiki.yaml. I've sent a patch for review, and we'll look to deploy this next week.

I would expect that to have the same effect as the previous change (the values from additional_rewrites just get interpolated into the mediawiki-vhost.conf.erb template, which we tried to modify earlier). If this works, and the previous approach does not work, I'd like to know why! :)

I would expect that to have the same effect as the previous change (the values from additional_rewrites just get interpolated into the mediawiki-vhost.conf.erb template, which we tried to modify earlier). If this works, and the previous approach does not work, I'd like to know why! :)

For MW-on-K8s, it gets interpolated by a helm template

Change #1301338 merged by Blake:

[operations/puppet@production] mediawiki: Use utf-8 for text/plain and text/html.

https://gerrit.wikimedia.org/r/1301338

Mentioned in SAL (#wikimedia-operations) [2026-06-15T10:10:37Z] <blake@deploy1003> Started scap sync-world: apache config change (T428772)

Mentioned in SAL (#wikimedia-operations) [2026-06-15T10:11:29Z] <blake@deploy1003> blake: apache config change (T428772) synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2026-06-15T10:16:18Z] <blake@deploy1003> Finished scap sync-world: apache config change (T428772) (duration: 06m 41s)

Change #1303353 had a related patch set uploaded (by Blake; author: Blake):

[operations/puppet@production] test_main: Remove redundant wildcards.

https://gerrit.wikimedia.org/r/1303353

Change #1303353 merged by Blake:

[operations/puppet@production] test_main: Remove redundant wildcards.

https://gerrit.wikimedia.org/r/1303353