From 726798c8cb9262d923d4ace68352adfa046c74cf Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Fri, 17 Dec 2010 16:59:02 +0000 Subject: [PATCH] Fix order, escape quotes first or the field delimiters get doubled --- etemplate/inc/class.nextmatch_widget.inc.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/etemplate/inc/class.nextmatch_widget.inc.php b/etemplate/inc/class.nextmatch_widget.inc.php index f15981e5b9..ebf2a72f31 100644 --- a/etemplate/inc/class.nextmatch_widget.inc.php +++ b/etemplate/inc/class.nextmatch_widget.inc.php @@ -1172,11 +1172,14 @@ class nextmatch_widget } $value = implode(', ',$value); + if (strpos($value,'"') !== false) + { + $value = '"'.str_replace('"', '""', $value).'"'; // Escape double quotes + } if (strpos($value,$separator) !== false || strpos($value,"\n") !== false || strpos($value,"\r") !== false) { $value = '"'.str_replace(array('\\','"'),array('\\\\','\\"'),$value).'"'; - // to avoid early linebreak by Excel, escape double quotes in text - $value = str_replace(array("\r\n", '"'), array("\n",'""'), $value); + $value = str_replace("\r\n", "\n", $value); // to avoid early linebreak by Excel } $out[] = $value; }