Relationship Graph
View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0036987 | mantisbt | csv | public | 2026-03-19 05:16 | 2026-04-18 10:31 |
| Reporter | vicsuarez | Assigned To | dregad | ||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | resolved | Resolution | fixed | ||
| Product Version | 2.28.1 | ||||
| Target Version | 2.28.2 | Fixed in Version | 2.28.2 | ||
| Summary | 0036987: csv_escape_string: incorrect result with int/float custom values when csv_injection_protection is active | ||||
| Description | Wrong casting in function csv_escape_string (csv_api.php) results in a "tab" prefixed in numeric values of custom fields. This makes more difficult manage types in created CSV files. This issue generates a warning: "PHP Warning: Trying to access array offset on int in php shell code on line xxxxx" | ||||
| Steps To Reproduce | 1- Click on "CSV Export button on "View Issues" page | ||||
| Additional Information | One possible solution could be replace this code:
with this: | ||||
| Tags | No tags attached. | ||||
|
Thanks for the report. I confirm that when csv_escape_string() receives non-string data, the lack of type cast will lead to always (and sometimes incorrectly) qualifying the string as risky, resulting in tab character to be prepended. |
|
|
PR https://github.com/mantisbt/mantisbt/pull/2198 @vicsuarez Please test the proposed patch let let me know your feedback. Note that even after the fix, negative values will still be prefixed by a tab, and Excel will therefore treated them as string instead of number. This cannot be avoided while $g_csv_injection_protection = ON. |
|
|
Be careful, csv_api.php is broken after patch (lines 122 to 126). |
|
|
Applying the patch (as primarily intended) is working, fixing the problem from this issue. This is the original function (I THINK): |
|
|
Thanks for the feedback. To make it better next time: BAD: csv_api.php is broken Anyway, sorry about posting a PR with a syntax error, that was sloppy - I messed up when splitting a commit, and should have re-tested the code before pushing the branch. GitHub actions should have caught this, but for some reason the CI pipeline did not run. I just pushed a fix to the PR's branch, hopefully it will be OK this time. |
|
|
Thank you very much, and excuse me for the incorrect expression. |
|
|
MantisBT: master-2.28 b80bd8bd 2026-03-19 14:21 Details Diff |
Ensure csv_escape_string() deals with a string This prevents a PHP warning when using array dereferencing form to get $p_string's first character. When this happened, the strpos() call would return 0, leading to always (and sometimes incorrectly) qualifying the string as risky, resulting in a tab character to be prepended. Note: using a type cast instead of string TypeDef in function signature to avoid regression issues in case some callers pass NULL. Fixes 0036987 |
Affected Issues 0036987 |
|
| mod - core/csv_api.php | Diff File | ||
related to
child of
duplicate of