Defect #44782
openPlugin update check fails: check_updates is served as text/plain with X-Content-Type-Options: nosniff
Description
Administration > Plugins > "Check for updates" fails with the alert "Unable to retrieve plugin informations from www.redmine.org". I can reproduce it on a fresh Redmine 7.0.3 (official Docker image, SQLite) with the view_customize and redmine_issue_templates plugins installed.
The plugins page loads https://www.redmine.org/plugins/check_updates as JSONP, so the browser requests it through a script tag. www.redmine.org answers with status 200 and a valid JSONP body, but sends it as text/plain together with X-Content-Type-Options: nosniff:
$ curl -s -D - -G 'https://www.redmine.org/plugins/check_updates' \
--data-urlencode 'callback=cb' \
--data-urlencode 'v=7.0.3.stable' \
--data-urlencode 'p[view_customize][v]=3.6.0'
HTTP/1.1 200 OK
x-content-type-options: nosniff
content-type: text/plain; charset=utf-8
(other headers omitted)
cb({"view_customize":{"url":"https://www.redmine.org/plugins/view_customize","c":"3.6.0"}})
With nosniff set, the browser refuses to execute a script response whose content type is not a JavaScript type. The callback never runs and jQuery calls the error handler.
To confirm that the headers are the cause, I served the same JSONP body from a local test server and loaded it through a script tag from the plugins page, in a Chromium 156 based browser:
| Response headers | Result |
|---|---|
text/plain with nosniff (what www.redmine.org sends) |
blocked |
text/javascript with nosniff |
callback runs |
text/plain without nosniff |
callback runs |
| the www.redmine.org endpoint itself | blocked |
The failure does not depend on the installed plugins. A request that contains only view_customize fails in the browser too.
The symptom matches #38382, which was fixed on the server in 2023. #44583 describes a different problem: there the server returns a 500 for a long Referer, while here it returns a 200.
Serving the response as text/javascript should fix it.
No data to display