Project

General

Profile

Bug #28248 ยป substUrlsInPlainText.diff

Robert Heel, 2011-07-15 23:33

View differences:

typo3_src-4.5.3/t3lib/class.t3lib_div.php 2011-07-15 23:30:34.000000000 +0200
* @see makeRedirectUrl()
*/
public static function substUrlsInPlainText($message, $urlmode = '76', $index_script_url = '') {
// Substitute URLs with shorter links:
foreach (array('http', 'https') as $protocol) {
$urlSplit = explode($protocol . '://', $message);
foreach ($urlSplit as $c => &$v) {
if ($c) {
$newParts = preg_split('/\s|[<>"{}|\\\^`()\']/', $v, 2);
$newURL = $protocol . '://' . $newParts[0];
switch ((string) $urlmode) {
case 'all':
$newURL = self::makeRedirectUrl($newURL, 0, $index_script_url);
break;
case '76':
$newURL = self::makeRedirectUrl($newURL, 76, $index_script_url);
break;
}
$v = $newURL . substr($v, strlen($newParts[0]));
}
}
$message = implode('', $urlSplit);
}
return $message;
return preg_replace('/(http|https):\/\/.+(?=[\]\.\?]*([\! \'"()<>]+|$))/eiU','self::makeRedirectUrl("\\0",'.intval($urlmode).',"'.$index_script_url.'")',$message);
}
/**
    (1-1/1)