diff options
-rw-r--r-- | system/helpers/url_helper.php | 2 | ||||
-rw-r--r-- | tests/codeigniter/helpers/url_helper_test.php | 9 | ||||
-rw-r--r-- | user_guide_src/source/changelog.rst | 1 |
3 files changed, 11 insertions, 1 deletions
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index f6fb7d9eb..489f2d44e 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -393,7 +393,7 @@ if ( ! function_exists('auto_link')) function auto_link($str, $type = 'both', $popup = FALSE) { // Find and replace any URLs. - if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[^\s()<>;]+\w/?#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) + if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[a-z0-9]+(-+[a-z0-9]+)*(\.[a-z0-9]+(-+[a-z0-9]+)*)+(/([^\s()<>;]+\w)?/?)?#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { // Set our target HTML if using popup links. $target = ($popup) ? ' target="_blank"' : ''; diff --git a/tests/codeigniter/helpers/url_helper_test.php b/tests/codeigniter/helpers/url_helper_test.php index 5fbc364bf..83a8c0ec2 100644 --- a/tests/codeigniter/helpers/url_helper_test.php +++ b/tests/codeigniter/helpers/url_helper_test.php @@ -77,4 +77,13 @@ class Url_helper_test extends CI_TestCase { } } + // -------------------------------------------------------------------- + + public function test_issue_5331() + { + $this->assertEquals( + 'this is some text that includes '.safe_mailto('www.email@domain.com').' which is causing an issue', + auto_link('this is some text that includes www.email@domain.com which is causing an issue') + ); + } } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index eb879c5a8..1641f7c97 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -21,6 +21,7 @@ Bug fixes for 3.1.7 - Fixed a bug (#5278) - :doc:`URL Helper <helpers/url_helper>` function :php:func:`auto_link()` didn't detect trailing slashes in URLs. - Fixed a regression (#5282) - :doc:`Query Builder <database/query_builder>` method ``count_all_results()`` breaks ``ORDER BY`` clauses for subsequent queries. - Fixed a bug (#5279) - :doc:`Query Builder <database/query_builder>` didn't account for already escaped identifiers while applying database name prefixes. +- Fixed a bug (#5331) - :doc:`URL Helper <helpers/url_helper>` function :php:func:`auto_link()` converted e-mail addresses starting with 'www.' to both "url" and "email" links. Version 3.1.6 ============= |