* Fixed spam-protection of email adresses inserted by "mailto:..." in text.
authorKasper Skårhøj <kasper@typo3.org>
Wed, 31 Mar 2004 15:14:58 +0000 (15:14 +0000)
committerKasper Skårhøj <kasper@typo3.org>
Wed, 31 Mar 2004 15:14:58 +0000 (15:14 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@174 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/cms/tslib/class.tslib_content.php
typo3/sysext/cms/tslib/class.tslib_fe.php

index 649a7ce..bd08992 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2004-03-31  Kasper Skårhøj,,,  <kasper@typo3.com>
 
+       * Fixed spam-protection of email adresses inserted by "mailto:..." in text.
+
+2004-03-31  Kasper Skårhøj,,,  <kasper@typo3.com>
+
        * Fixed another small bug in detection of simulateStaticDocuments.
 
 2004-03-31  Kasper Skårhøj,,,  <kasper@typo3.com>
index 0162b29..0c866af 100755 (executable)
@@ -4117,16 +4117,23 @@ class tslib_cObj {
                $textstr = $textpieces[0];
                $initP = '?id='.$GLOBALS['TSFE']->id.'&type='.$GLOBALS['TSFE']->type;
                for($i=1; $i<$pieces; $i++)     {
-                       $len=strcspn($textpieces[$i],chr(32).chr(9).chr(13).chr(10));
+                       $len = strcspn($textpieces[$i],chr(32).chr(9).chr(13).chr(10));
                        if (trim(substr($textstr,-1))=='' && $len)      {
-                               $lastChar=substr($textpieces[$i],$len-1,1);
+                               $lastChar = substr($textpieces[$i],$len-1,1);
                                if (!ereg('[A-Za-z0-9]',$lastChar)) {$len--;}
 
-                               $parts[0]=substr($textpieces[$i],0,$len);
-                               $parts[1]=substr($textpieces[$i],$len);
-                               $linktxt=ereg_replace('\?.*','',$parts[0]);
+                               $parts[0] = substr($textpieces[$i],0,$len);
+                               $parts[1] = substr($textpieces[$i],$len);
+                               $linktxt = ereg_replace('\?.*','',$parts[0]);
                                if (!$GLOBALS['TSFE']->config['config']['jumpurl_enable'] || $GLOBALS['TSFE']->config['config']['jumpurl_mailto_disable'])      {
-                                       $res = '<a href="mailto:'.htmlspecialchars($parts[0]).'"'.$aTagParams.'>';
+                                       if ($GLOBALS['TSFE']->spamProtectEmailAddresses)        {
+                                               $mailToUrl = "javascript:linkTo_UnCryptMailto('".$GLOBALS['TSFE']->encryptEmail('mailto:'.$parts[0])."');";
+                                               $atLabel = trim($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_atSubst']);
+                                               $linktxt = str_replace('@',$atLabel ? $atLabel : '(at)', $linktxt);
+                                       } else {
+                                               $mailToUrl = 'mailto:'.$parts[0];
+                                       }
+                                       $res = '<a href="'.htmlspecialchars($mailToUrl).'"'.$aTagParams.'>';
                                } else {
                                        $res = '<a href="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode('mailto:'.$parts[0]).$GLOBALS['TSFE']->getMethodUrlIdToken).'"'.$aTagParams.'>';
                                }
index fe48b62..f6d66fe 100755 (executable)
  * 2342:     function makeSimulFileName($inTitle,$page,$type,$addParams='',$no_cache='')       
  * 2389:     function simulateStaticDocuments_pEnc_onlyP_proc($linkVars)
  * 2417:     function getSimulFileName()       
- * 2430:     function encryptEmail($string,$back=0)    
+ * 2430:     function encryptEmail($string,$back=0)
  * 2447:     function checkFileInclude($incFile)       
  * 2462:     function newCObj()        
  * 2475:     function setAbsRefPrefix()        
@@ -2469,11 +2469,11 @@ if (version == "n3") {
         * @return      string          encoded/decoded version of $string
         */
        function encryptEmail($string,$back=0)  {
-               $out='';
-               for ($a=0;$a<strlen($string);$a++)      {
+               $out = '';
+               for ($a=0; $a<strlen($string); $a++)    {
                        $charValue = ord(substr($string,$a,1));
-                       $charValue+=intval($GLOBALS['TSFE']->spamProtectEmailAddresses)*($back?-1:1);
-                       $out.=chr($charValue);
+                       $charValue+= intval($GLOBALS['TSFE']->spamProtectEmailAddresses)*($back?-1:1);
+                       $out.= chr($charValue);
                }
                return $out;
        }
@@ -2486,7 +2486,7 @@ if (version == "n3") {
         * @see tslib_cObj::PHP_SCRIPT(), tslib_feTCE::includeScripts(), tslib_menu::includeMakeMenu()
         */
        function checkFileInclude($incFile)     {
-               return !$GLOBALS['TYPO3_CONF_VARS']['FE']['noPHPscriptInclude'] 
+               return !$GLOBALS['TYPO3_CONF_VARS']['FE']['noPHPscriptInclude']
                        || substr($incFile,0,14)=='media/scripts/'
                        || substr($incFile,0,4+strlen(TYPO3_mainDir))==TYPO3_mainDir.'ext/'
                        || substr($incFile,0,7+strlen(TYPO3_mainDir))==TYPO3_mainDir.'sysext/'