[openstreetmap/openstreetmap-website] Stop Commons from redirecting outside CSP (PR #6202)

Minh Nguyễn notifications at github.com
Fri Jul 18 00:12:24 UTC 2025


@1ec5 commented on this pull request.

This is another subtle difference between Special:Redirect and the MediaWiki API, which is why the initial request for the item details doesn’t run into this problem.

> @@ -171,8 +171,8 @@
       .addClass("bg-body-tertiary");
 
     if (icon && OSM.WIKIMEDIA_COMMONS_URL) {
-      let src = OSM.WIKIMEDIA_COMMONS_URL + "Special:Redirect/file/" + encodeURIComponent(icon);
-      if (!icon.endsWith(".svg")) src += "?width=128";
+      let src = OSM.WIKIMEDIA_COMMONS_URL + "Special:Redirect/file/" + encodeURIComponent(icon) + "?mobileaction=toggle_view_desktop";

In cursory testing, this doesn’t cause subsequent user-initiated page loads on Commons to switch back to desktop view, which is good. Still a bit counterintuitive in this code, so a comment explaining the parameter would be a good idea.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6202#pullrequestreview-3031368828
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/6202/review/3031368828 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250717/f6643a77/attachment.htm>


More information about the rails-dev mailing list