Skip to content

Commit

Permalink
fix: auto_link() regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Sep 5, 2024
1 parent 6a43bc2 commit ea12427
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion system/Helpers/url_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ function safe_mailto(string $email, string $title = '', $attributes = ''): strin
function auto_link(string $str, string $type = 'both', bool $popup = false): string
{
// 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"' : '';

Expand Down

0 comments on commit ea12427

Please sign in to comment.