From 0c84881e84b2aca0eabd218009cb928ee381f2bc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kasper=20Sk=C3=A5rh=C3=B8j?= <kasper@typo3.org>
Date: Wed, 31 Mar 2004 15:14:58 +0000
Subject: [PATCH] * Fixed spam-protection of email adresses inserted by
 "mailto:..." in text.

git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@174 709f56b5-9817-0410-a4d7-c38de5d9e867
---
 ChangeLog                                     |  4 ++++
 .../sysext/cms/tslib/class.tslib_content.php  | 19 +++++++++++++------
 typo3/sysext/cms/tslib/class.tslib_fe.php     | 12 ++++++------
 3 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 649a7ceaf252..bd08992f4d84 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+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.
diff --git a/typo3/sysext/cms/tslib/class.tslib_content.php b/typo3/sysext/cms/tslib/class.tslib_content.php
index 0162b299b529..0c866af8bd2d 100755
--- a/typo3/sysext/cms/tslib/class.tslib_content.php
+++ b/typo3/sysext/cms/tslib/class.tslib_content.php
@@ -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.'>';
 				}
diff --git a/typo3/sysext/cms/tslib/class.tslib_fe.php b/typo3/sysext/cms/tslib/class.tslib_fe.php
index fe48b6210b10..f6d66fecedc0 100755
--- a/typo3/sysext/cms/tslib/class.tslib_fe.php
+++ b/typo3/sysext/cms/tslib/class.tslib_fe.php
@@ -119,7 +119,7 @@
  * 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/'
-- 
GitLab