Making WordPress.org

Changeset 11242


Ignore:
Timestamp:
09/17/2021 01:59:58 AM (5 years ago)
Author:
dd32
Message:

Comment Moderation: Exclude links to ​https://github.com/WordPress/* as part of the link count in comments.

This makes it easier for the Core/Editor teams to reference GitHub issues in weekly posts.

This commit also tightens the URL matching, to avoid potential workarounds where a url 'contains' a whitelisted url, but isn't that url.

See ​https://wordpress.slack.com/archives/C02QB8GMM/p1631707101032800

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/mu-plugins/pub/comment-moderation.php

    r9593 r11242  
    2323
    2424        // Get whitelisted URLs.
    25         // Note: unnecessary to specify subdomains
     25        // Note: unnecessary to specify subdomains, do not include trailing slash.
    2626        $whitelist_urls = array(
    2727                'wordpress.org',
     28                'github.com/WordPress',
    2829        );
    2930
    … …  
    6061
    6162                // Count the number of occurrences of this particular whitelisted URL.
    62                 $num_whitelist_links = preg_match_all( '%<a [^>]*href=[\'\"]https?://[^/>]*' . preg_quote( $url, '%' ) . '%i', $comment, $out );
     63                $num_whitelist_links = preg_match_all( '%<a [^>]*href=([\'\"])https?://([^/>]+\.)?' . preg_quote( $url, '%' ) . '(/|\\1)%i', $comment, $out );
    6364
    6465                // Increase the limit by the number of whitelisted URLs (so that they don't
Note: See TracChangeset for help on using the changeset viewer.