From aab9f0d91af4b73b7fb3042534dfe5c072682850 Mon Sep 17 00:00:00 2001 From: kkr-Christopher <91697610+kkr-Christopher@users.noreply.github.com> Date: Tue, 8 Mar 2022 19:00:48 +0100 Subject: [PATCH 1/2] Fix '=' in Google Sheets --- xlsxwriter.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xlsxwriter.class.php b/xlsxwriter.class.php index e4ebdc5eb..450ec4702 100644 --- a/xlsxwriter.class.php +++ b/xlsxwriter.class.php @@ -369,7 +369,7 @@ protected function writeCell(XLSXWriter_BuffererWriter &$file, $row_number, $col if (!is_scalar($value) || $value==='') { //objects, array, empty $file->write(''); } elseif (is_string($value) && $value[0]=='='){ - $file->write(''.self::xmlspecialchars($value).''); + $file->write(''.self::xmlspecialchars(ltrim($value, '=')).''); } elseif ($num_format_type=='n_date') { $file->write(''.intval(self::convert_date_time($value)).''); } elseif ($num_format_type=='n_datetime') { From caa33a241b795f6abced4b587d0e8a7288dd9a30 Mon Sep 17 00:00:00 2001 From: asalonen Date: Thu, 23 Feb 2023 14:24:56 +0000 Subject: [PATCH 2/2] Add missing property, fix call to htmlspecialchars by ensuring the parameter is string --- xlsxwriter.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xlsxwriter.class.php b/xlsxwriter.class.php index e4ebdc5eb..958ea6cf8 100644 --- a/xlsxwriter.class.php +++ b/xlsxwriter.class.php @@ -19,6 +19,7 @@ class XLSXWriter protected $company; protected $description; protected $keywords = array(); + protected $tempdir; protected $current_sheet; protected $sheets = array(); @@ -764,7 +765,7 @@ public static function xmlspecialchars($val) //note, badchars does not include \t\n\r (\x09\x0a\x0d) static $badchars = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f"; static $goodchars = " "; - return strtr(htmlspecialchars($val, ENT_QUOTES | ENT_XML1), $badchars, $goodchars);//strtr appears to be faster than str_replace + return strtr(htmlspecialchars((string)$val, ENT_QUOTES | ENT_XML1), $badchars, $goodchars);//strtr appears to be faster than str_replace } //------------------------------------------------------------------ public static function array_first_key(array $arr)