From c859e1db31388afa9cd581e66e2d8b30148add3a Mon Sep 17 00:00:00 2001 From: Max Pozdeev Date: Sat, 29 Jun 2019 20:19:40 +0300 Subject: [PATCH] - escape formulas in CSV export (fix) --- src/export.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/export.php b/src/export.php index 66e19f6..2c360f9 100644 --- a/src/export.php +++ b/src/export.php @@ -66,7 +66,8 @@ function escape_csv($v) { //escape formulas $nf = ''; - if (strlen($v) > 0 && in_array(substr($v, 0, 1), array('=', '+', '-', '@'))) { + $trimmed = ltrim($v); + if (strlen($trimmed) > 0 && in_array(substr($trimmed, 0, 1), array('=', '+', '-', '@'))) { $nf = "'"; } return '"'. $nf. str_replace('"', '""', $v). '"';