Escape double quotes in a string value unless it's an empty string value
This commit is contained in:
parent
51453db41e
commit
cba0e13b2a
|
|
@ -43,7 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
||||||
Note that this method is used when translating Excel functions between `en_us` and other locale languages, as well as when converting formulae between different spreadsheet formats (e.g. Ods to Excel).
|
Note that this method is used when translating Excel functions between `en_us` and other locale languages, as well as when converting formulae between different spreadsheet formats (e.g. Ods to Excel).
|
||||||
|
|
||||||
Nor is this a perfect solution, as there may still be issues when function calls have array arguments that themselves contain function calls; but it's still better than the current logic.
|
Nor is this a perfect solution, as there may still be issues when function calls have array arguments that themselves contain function calls; but it's still better than the current logic.
|
||||||
|
- Fix for escaping double quotes within a formula [Issue #1971](https://github.com/PHPOffice/PhpSpreadsheet/issues/1971) [PR #2651](https://github.com/PHPOffice/PhpSpreadsheet/pull/2651)
|
||||||
|
|
||||||
## 1.22.0 - 2022-02-18
|
## 1.22.0 - 2022-02-18
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,10 @@ class Functions
|
||||||
if (is_bool($condition)) {
|
if (is_bool($condition)) {
|
||||||
return '=' . ($condition ? 'TRUE' : 'FALSE');
|
return '=' . ($condition ? 'TRUE' : 'FALSE');
|
||||||
} elseif (!is_numeric($condition)) {
|
} elseif (!is_numeric($condition)) {
|
||||||
|
if ($condition !== '""') { // Not an empty string
|
||||||
|
// Escape any quotes in the string value
|
||||||
|
$condition = preg_replace('/"/ui', '""', $condition);
|
||||||
|
}
|
||||||
$condition = Calculation::wrapResult(strtoupper($condition));
|
$condition = Calculation::wrapResult(strtoupper($condition));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,18 @@ return [
|
||||||
'<"<A"',
|
'<"<A"',
|
||||||
'<<A',
|
'<<A',
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'="A"',
|
||||||
|
'=A',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'="""A"""',
|
||||||
|
'="A"',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'="""A""B"""',
|
||||||
|
'="A"B"',
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'<>"< PLEASE SELECT >"',
|
'<>"< PLEASE SELECT >"',
|
||||||
'<>< Please Select >',
|
'<>< Please Select >',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue