/**
  * Takes a clear-text message body for a plain text email, finds all 'http://' links and if they are longer than 76 chars they are converted to a shorter URL with a hash parameter. The real parameter is stored in the database and the hash-parameter/URL will be redirected to the real parameter when the link is clicked.
  * This function is about preserving long links in messages.
  *
  * @param string $message Message content
  * @param string $urlmode URL mode; "76" or "all
  * @param string $index_script_url URL of index script (see makeRedirectUrl())
  * @return string Processed message content
  * @see makeRedirectUrl()
  */
 public static function substUrlsInPlainText($message, $urlmode = '76', $index_script_url = '')
 {
     switch ((string) $urlmode) {
         case '':
             $lengthLimit = FALSE;
             break;
         case 'all':
             $lengthLimit = 0;
             break;
         case '76':
         default:
             $lengthLimit = (int) $urlmode;
     }
     if ($lengthLimit === FALSE) {
         // No processing
         $messageSubstituted = $message;
     } else {
         $messageSubstituted = preg_replace_callback('/(http|https):\\/\\/.+(?=[\\]\\.\\?]*([\\! \'"()<>]+|$))/iU', function (array $matches) use($lengthLimit, $index_script_url) {
             return GeneralUtility::makeRedirectUrl($matches[0], $lengthLimit, $index_script_url);
         }, $message);
     }
     return $messageSubstituted;
 }