Making WordPress.org

Changeset 13213


Ignore:
Timestamp:
02/15/2024 03:21:06 AM (7 months ago)
Author:
dd32
Message:

Trac: Github PRs: Load GitHub embedded images directly, avoiding CORS.

See #7442.

Location:
sites/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/functions.php

    r13081 r13213  
    398398
    399399    // Convert Images (Must happen prior to Links, as the only difference is a preceeding !)
    400     $desc = preg_replace( '#!\[(.+?)\]\(https?://(.+?)\)#', '[[Image(https://i0.wp.com/$2)]]', $desc );
     400    $desc = preg_replace( '#!\[(.+?)\]\((.+?)\)#', '[[Image($2)]]', $desc );
    401401    // Convert Images embedded as `<img>`.
    402     $desc = preg_replace( '#<img[^>]+src=(["\'])https?://(.+?)\\1[^>]*>#', '[[Image(https://i0.wp.com/$2)]]', $desc );
     402    $desc = preg_replace( '#<img[^>]+src=(["\'])(.+?)\\1[^>]*>#', '[[Image($2)]]', $desc );
    403403
    404404    // Convert Links.
  • sites/trunk/trac.wordpress.org/conf/common-extended.ini

    r11310 r13213  
    5656max_size = 1048576
    5757split_page_names = false
     58safe_origins = https://github.com/
    5859
    5960[ticket]
  • sites/trunk/trac.wordpress.org/templates/site.html

    r13191 r13213  
    55
    66<?python
    7     scripts_version = '216'
     7    scripts_version = '217'
    88    project_slug = req.environ['HTTP_HOST'].split(':')[0].split('.')[0]
    99    wporg_endpoint = 'https://make.wordpress.org/' + project_slug + '/'
  • sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js

    r12771 r13213  
    17431743                // Fetch the PRs immediately
    17441744                fetchPRs();
     1745
     1746                // deProxy github images, CORS changes.
     1747                deProxyImages();
     1748            }
     1749
     1750            // See https://meta.trac.wordpress.org/ticket/7442
     1751            function deProxyImages() {
     1752                $('img[src*="i0.wp.com/github.com/"]').each( function() {
     1753                    var $this = $(this), $parent = $this.parent('a');
     1754                    $this.removeAttr('crossorigin'); // We trust GitHub for these images.
     1755                    $this.prop( 'src', $this.prop('src').replace(/i0\.wp\.com/, '' ) );
     1756                    $this.prop( 'alt', $this.prop('alt').replace(/i0\.wp\.com/, '' ) );
     1757                    $this.prop( 'title', $this.prop('title').replace(/i0\.wp\.com/, '' ) );
     1758                    $parent.prop( 'href', $parent.prop('href').replace(/i0\.wp\.com/, '' ) );
     1759                } );
    17451760            }
    17461761
Note: See TracChangeset for help on using the changeset viewer.