Fix: correct minor bugs in the import/export workflow - #656
Conversation
| TemplateRenderer::getInstance()->display('@datainjection/clientinjection_result.html.twig', $data); | ||
| } | ||
|
|
||
| private static function escapeCsvFormula($value) |
There was a problem hiding this comment.
New security function with no unit test. It is a pure function with several edge cases worth pinning (empty string, non-string passthrough, each of the four trigger characters, a value starting with a safe character). Without a test, a future refactor or PHP upgrade could silently break the protection and let formula-injection payloads through.
There was a problem hiding this comment.
Missing PHP 8.2 type declarations. The function accepts any type (non-strings are passed through unchanged) and returns the same type. Project rules require strict typing everywhere.
| private static function escapeCsvFormula($value) | |
| private static function escapeCsvFormula(mixed $value): mixed |
|
|
||
| private static function escapeCsvFormula($value) | ||
| { | ||
| if (is_string($value) && isset($value[0]) && str_contains('=+-@', $value[0])) { |
There was a problem hiding this comment.
Arguments are in an unconventional order: str_contains reads as "does haystack contain needle", so str_contains('=+-@', $value[0]) means "does '=+-@' contain the first char?"
which is correct but non-obvious. in_array makes the intent explicit and self-documents the set of trigger characters.
| if (is_string($value) && isset($value[0]) && str_contains('=+-@', $value[0])) { | |
| if (is_string($value) && isset($value[0]) && in_array($value[0], ['=', '+', '-', '@'], true)) { |
Checklist before requesting a review
Please delete options that are not relevant.
Description
Screenshots (if appropriate):