From 637f608827aceeb11d96f68942d8b870c3dc8051 Mon Sep 17 00:00:00 2001 From: OlyaHryhorenko Date: Fri, 22 Dec 2023 17:12:32 +0200 Subject: [PATCH 1/4] Process string starting with www as email in make_clickable(). --- src/wp-includes/formatting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index bc150c8a537cb..3d311893a3a5b 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -3135,8 +3135,8 @@ function make_clickable( $text ) { $ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret ); - $ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret ); $ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret ); + $ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret ); $ret = substr( $ret, 1, -1 ); // Remove our whitespace padding. $r .= $ret; From b32854f36612389d6fc6fd67c828b2916b7a97c0 Mon Sep 17 00:00:00 2001 From: OlyaHryhorenko Date: Fri, 22 Dec 2023 17:29:01 +0200 Subject: [PATCH 2/4] Update data for UnitTests --- tests/phpunit/tests/formatting/makeClickable.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/phpunit/tests/formatting/makeClickable.php b/tests/phpunit/tests/formatting/makeClickable.php index 8620f1efcb15e..c67358d9356ee 100644 --- a/tests/phpunit/tests/formatting/makeClickable.php +++ b/tests/phpunit/tests/formatting/makeClickable.php @@ -32,6 +32,7 @@ public function data_valid_mailto() { array( 'Foo.Bar@a.b.c.d.example.com' ), array( '0@example.com' ), array( 'foo@example-example.com' ), + array( 'www.foo.com@gmail.com' ), ); } From 2b7684f1cb7511d9e5796717937a5c3bd3f400c8 Mon Sep 17 00:00:00 2001 From: OlyaHryhorenko Date: Wed, 27 Dec 2023 09:49:05 +0200 Subject: [PATCH 3/4] Improve RegEx for ftp address to not match emails. --- src/wp-includes/formatting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 3d311893a3a5b..29f45136a5283 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -3135,8 +3135,8 @@ function make_clickable( $text ) { $ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret ); + $ret = preg_replace_callback( '#(^ftp://([a-zA-Z0-9.-]+)(:\d+)?(/[a-zA-Z0-9._/%-]*)?$)#i', '_make_web_ftp_clickable_cb', $ret ); $ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret ); - $ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret ); $ret = substr( $ret, 1, -1 ); // Remove our whitespace padding. $r .= $ret; From ed4ccddb4fa6b3d3ef710a69dc688c0bf7065091 Mon Sep 17 00:00:00 2001 From: OlyaHryhorenko Date: Wed, 27 Dec 2023 10:10:45 +0200 Subject: [PATCH 4/4] Improve RegEx for ftp address to not match emails. --- src/wp-includes/formatting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 29f45136a5283..3d487d1c1d142 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -3135,7 +3135,7 @@ function make_clickable( $text ) { $ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret ); - $ret = preg_replace_callback( '#(^ftp://([a-zA-Z0-9.-]+)(:\d+)?(/[a-zA-Z0-9._/%-]*)?$)#i', '_make_web_ftp_clickable_cb', $ret ); + $ret = preg_replace_callback( '#([\s>])((ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret ); $ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret ); $ret = substr( $ret, 1, -1 ); // Remove our whitespace padding.