Skip to content

Commit 73cac44

Browse files
authored
Merge pull request #2797 from nextcloud/backport/2772/stable5
[stable5] fix: properly set string values in exports to escape formulas
2 parents c306372 + 264ab0f commit 73cac44

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

.github/workflows/phpunit-sqlite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
php-version: ${{ matrix.php-versions }}
108108
# https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
109109
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
110-
coverage: none
110+
coverage: xdebug
111111
ini-file: development
112112
# Temporary workaround for missing pcntl_* in PHP 8.3
113113
ini-values: disable_functions=

lib/Service/SubmissionService.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,12 @@ private function exportData(array $header, array $data, string $fileFormat, ?Fil
311311
->getAlignment()
312312
->setWrapText(true);
313313
} else {
314-
$activeWorksheet->setCellValue([$column, $row], $value);
315-
316-
// Quote cell values that start with '=' to prevent evaluation of formulas
314+
// Explicitly set the type of the value to string for values that start with '=' to prevent it being interpreted as formulas
317315
if (is_string($value) && str_starts_with($value, '=')) {
318-
$activeWorksheet->getCell([$column, $row])->getStyle()->setQuotePrefix(true);
316+
$activeWorksheet->getCell([$column, $row])
317+
->setValueExplicit($value);
318+
} else {
319+
$activeWorksheet->setCellValue([$column, $row], $value);
319320
}
320321
}
321322
}

0 commit comments

Comments
 (0)