mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-05 07:58:35 +01:00
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. Built from https://develop.svn.wordpress.org/trunk@59143 git-svn-id: http://core.svn.wordpress.org/trunk@58539 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
eba0127372
commit
0d0634dbc9
@ -2943,6 +2943,10 @@ function _make_url_clickable_cb( $matches ) {
|
|||||||
$suffix = $matches[3];
|
$suffix = $matches[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( isset( $matches[4] ) && ! empty( $matches[4] ) ) {
|
||||||
|
$url .= $matches[4];
|
||||||
|
}
|
||||||
|
|
||||||
// Include parentheses in the URL only if paired.
|
// Include parentheses in the URL only if paired.
|
||||||
while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) {
|
while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) {
|
||||||
$suffix = strrchr( $url, ')' ) . $suffix;
|
$suffix = strrchr( $url, ')' ) . $suffix;
|
||||||
@ -3115,6 +3119,7 @@ function make_clickable( $text ) {
|
|||||||
)*
|
)*
|
||||||
)
|
)
|
||||||
(\)?) # 3: Trailing closing parenthesis (for parenthesis balancing post processing).
|
(\)?) # 3: Trailing closing parenthesis (for parenthesis balancing post processing).
|
||||||
|
(\\.\\w{2,6})? # 4: Allowing file extensions (e.g., .jpg, .png).
|
||||||
~xS';
|
~xS';
|
||||||
/*
|
/*
|
||||||
* The regex is a non-anchored pattern and does not have a single fixed starting character.
|
* The regex is a non-anchored pattern and does not have a single fixed starting character.
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.7-alpha-59142';
|
$wp_version = '6.7-alpha-59143';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user