Make WordPress Core


Ignore:
Timestamp:
09/30/2024 11:27:34 PM (8 months ago)
Author:
peterwilsoncc
Message:

Formatting: Improve parenthesis handling in make_clickable().

Improve the regular expression for making links clickable to account for parenthesis in links containing an extension, for example: http://wordpress.org/my-image(2).jpg.

Props coquardcyr, hellofromtonya, parthvataliya, rhellewellgmailcom.
Fixes #62037.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r59120 r59143  
    29442944    }
    29452945
     2946    if ( isset( $matches[4] ) && ! empty( $matches[4] ) ) {
     2947        $url .= $matches[4];
     2948    }
     2949
    29462950    // Include parentheses in the URL only if paired.
    29472951    while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) {
     
    31163120                )
    31173121                (\)?)                                          # 3: Trailing closing parenthesis (for parenthesis balancing post processing).
     3122                (\\.\\w{2,6})?                                 # 4: Allowing file extensions (e.g., .jpg, .png).
    31183123            ~xS';
    31193124            /*
Note: See TracChangeset for help on using the changeset viewer.