From 98122085f766f28137e38ee8ad81923589ab625a Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Thu, 5 May 2011 08:59:54 +0000 Subject: [PATCH] fixing a problem of swallowed whitespace while converting html to text --- phpgwapi/inc/class.translation.inc.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/phpgwapi/inc/class.translation.inc.php b/phpgwapi/inc/class.translation.inc.php index 49f5e76351..c8a827f022 100644 --- a/phpgwapi/inc/class.translation.inc.php +++ b/phpgwapi/inc/class.translation.inc.php @@ -1183,11 +1183,16 @@ class translation { if (stripos($elem,'
')===false)
 					{
-						$elem = preg_replace('@(\r\n)@i',' ',$elem);
+						//$elem = str_replace('@(\r\n)@i',' ',$elem);
+						$elem = str_replace(array("\r\n","\n"),' ',$elem);
 					}
 				}
 				$_html = implode('',$contentArr);
 			}
+			else
+			{
+				$_html = str_replace(array("\r\n","\n"),' ',$_html);
+			}
 		}
 		$tags = array (
 			0 => '~]*>\r*\n*~si',
@@ -1233,6 +1238,8 @@ class translation
 			$_html = preg_replace('~<[^>^@]+>~s','',$_html);
 			//$_html = strip_tags($_html, '');
 		}
+		// reducing double \r\n to single ones
+		//$_html = str_replace("\r\n\r\n", "\r\n", $_html); // ToDo: this needsv to be more sophosticated 
 		// reducing spaces
 		$_html = preg_replace('~ +~s',' ',$_html);
 		// we dont reduce whitespace at the start or the end of the line, since its used for structuring the document
@@ -1240,7 +1247,9 @@ class translation
 		#$_html = preg_replace('~\s+$~m','',$_html);
 		// restoring ampersands
 		$_html = str_replace('#amper#sand#','&',$_html);
+		//error_log(__METHOD__.__LINE__.' Charset:'.$displayCharset.' -> '.$_html);
 		$_html = html_entity_decode($_html, ENT_COMPAT, $displayCharset);
+		//error_log(__METHOD__.__LINE__.' Charset:'.$displayCharset.' After html_entity_decode: -> '.$_html);
 		//self::replaceEmailAdresses($_html);
 		#error_log($text);
 		$pos = strpos($_html, 'blockquote');