Making WordPress.org

Changeset 7314


Ignore:
Timestamp:
06/16/2018 10:23:32 AM (6 years ago)
Author:
ocean90
Message:

Translate, Custom Warnings: Add a whitelist for the last URL character to reduce the number of false-positives for mismatching URLs.

Fixes #1401.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-custom-warnings/wporg-gp-custom-warnings.php

    r3390 r7314  
    3434     */
    3535    public function warning_mismatching_urls( $original, $translation ) {
    36         // Any http/https/schemeless URLs which are not encased in quotation marks nor contain whitespace
    37         $urls_regex = '@(?<![\'"])((https?://|(?<![:\w])//)[^\s]+)(?![\'"])@i';
     36        // Any http/https/schemeless URLs which are not encased in quotation marks
     37        // nor contain whitespace and end with a valid URL ending char.
     38        $urls_regex = '@(?<![\'"])((https?://|(?<![:\w])//)[^\s]+[a-z0-9\-_&=#/])(?![\'"])@i';
    3839
    3940        preg_match_all( $urls_regex, $original, $original_urls );
Note: See TracChangeset for help on using the changeset viewer.