X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Futil.php;h=be92f422fbb507d5657c81d0e3fe809afc32028f;hb=bdd9f6ce1d9bafc1c534aec224fa0ad1452779c1;hp=0655ebf276e4677ad9852b47a000bf6cd58b0a91;hpb=bb2cb65c2aa763c8b28c41b9811c6026a11482db;p=quix0rs-gnu-social.git
diff --git a/lib/util.php b/lib/util.php
index 0655ebf276..be92f422fb 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -394,12 +394,26 @@ function common_render_text($text)
function common_replace_urls_callback($text, $callback) {
// Start off with a regex
- preg_match_all('#(?:(?:(?:https?|ftps?|mms|rtsp|gopher|news|nntp|telnet|wais|file|prospero|webcal|xmpp|irc)://|(?:mailto|aim|tel):)[^.\s]+\.[^\s]+|(?:[^.\s/]+\.)+(?:museum|travel|[a-z]{2,4})(?:[:/][^\s]*)?)#i', $text, $matches);
+ $regex = '#
+ (?:
+ (?:
+ (?:https?|ftps?|mms|rtsp|gopher|news|nntp|telnet|wais|file|prospero|webcal|xmpp|irc)://
+ |
+ (?:mailto|aim|tel):
+ )
+ [^.\s]+\.[^\s]+
+ |
+ (?:[^.\s/:]+\.)+
+ (?:museum|travel|[a-z]{2,4})
+ (?:[:/][^\s]*)?
+ )
+ #ix';
+ preg_match_all($regex, $text, $matches);
// Then clean up what the regex left behind
$offset = 0;
- foreach($matches[0] as $url) {
- $url = htmlspecialchars_decode($url);
+ foreach($matches[0] as $orig_url) {
+ $url = htmlspecialchars_decode($orig_url);
// Make sure we didn't pick up an email address
if (preg_match('#^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$#i', $url)) continue;
@@ -442,6 +456,9 @@ function common_replace_urls_callback($text, $callback) {
if (!in_array($url_parts[2], $tlds)) continue;
+ // Put the url back the way we found it.
+ $url = (mb_strpos($orig_url, htmlspecialchars($url)) === FALSE) ? $url:htmlspecialchars($url);
+
// Call user specified func
$modified_url = $callback($url);
@@ -464,7 +481,7 @@ function common_linkify($url) {
}
else $title = '';
- return "$display";
+ return "$display";
}
function common_longurl($short_url)