diff --git a/inc/html.php b/inc/html.php index f61f98d..70654a0 100644 --- a/inc/html.php +++ b/inc/html.php @@ -70,8 +70,16 @@ function supportedFileTypes() { return sprintf(__('Supported file types are %1$s and %2$s.'), implode(', ', $types_allowed), $last_type); } +function _makeLinksClickable($matches) { + if (!isset($matches[1])) { + return ''; + } + $url = htmlentities($matches[1], ENT_QUOTES); + return '' . $url . ''; +} + function makeLinksClickable($text) { - $text = preg_replace('!(((f|ht)tp(s)?://)[-a-zA-Zа-яА-Я()0-9@:%\!_+.,~#?&;//=]+)!i', '$1', $text); + $text = preg_replace_callback('!(((f|ht)tp(s)?://)[-a-zA-Zа-яА-Я()0-9@:%\!_+.,~#?&;\'/=]+)!i', '_makeLinksClickable', $text); $text = preg_replace('/\(\(.*)\)\<\/a>/i', '($2)', $text); $text = preg_replace('/\(.*)\.\<\/a>/i', '$2.', $text); $text = preg_replace('/\(.*)\,\<\/a>/i', '$2,', $text);