diff --git a/api/src/Html.php b/api/src/Html.php
index b72a136f5f..fc5e79b21e 100644
--- a/api/src/Html.php
+++ b/api/src/Html.php
@@ -79,13 +79,26 @@ class Html
$NotHTTP = '(?)'; // avoid running again on http://www links already handled above
$Domain2 = 'www(\.[\w-.]+)';
$Subdir2 = '([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?';
- $optBracket = '(>|>)?';
+ $optBracket = '(>|>|>|;)?';
$Expr = '/' .$optBracket0. $NotAnchor . $NotHTTP . $Domain2 . $Subdir2 .$optBracket. '/i';
//$Expr = '/' . $NotAnchor . $NotHTTP . $Domain . $Subdir . $optBracket . '/i';
+ // use preg_replace_callback as we experienced problems with links such as
+ $result4 = preg_replace_callback( $Expr, function ($match) {
+ //error_log(__METHOD__.__LINE__.array2string($match));
+ if ($match[4]==';' && (strlen($match[3])-4) >=0 && strpos($match[3],'>',strlen($match[3])-4)!==false)
+ {
+ $match[3] = substr($match[3],0,strpos($match[3],'>',strlen($match[3])-4));
+ $match[4] = ">";
+ }
+ if ($match[4]==';'&&$match[3]==">")
+ {
+ $match[3] ='';
+ $match[4] = ">";
+ }
+ //error_log(__METHOD__.__LINE__.array2string($match));
+ return $match[1].""."www".$match[2].$match[3]."".$match[4];
+ }, $result3 );
}
- $result4 = preg_replace( $Expr, "$1www$2$3$4$5$6", $result3 );
-
- //return preg_replace( $Expr, "www$1$2$3 ", $result );
return $result4;
}