Skip to content

CSV export uses legacy backslash escaping, not RFC 4180 quote-doubling #4743

Open

Description

@objecttothis

Problem

PHP 8.4 deprecated omitting fputcsv()'s $escape parameter — the implicit default has historically been \ (backslash), a non-standard, PHP-specific escaping convention for quote characters embedded in CSV fields. A future PHP version will change the default to an empty string.

The codebase currently calls fputcsv() with an explicit $escape = '\' to preserve the existing (legacy) behavior and avoid the PHP 8.4 deprecation warning. This keeps output byte-for-byte identical to before, but it means any CSV export containing a literal double-quote character inside a field will produce a file using PHP's backslash-escaping dialect, which most non-PHP tools (Excel, Google Sheets, pandas, etc.) do not expect — the RFC 4180 standard escapes an embedded quote by doubling it (""), not by prefixing it with a backslash.

Proposed solution

Switch fputcsv() calls to $escape = '' (empty string), which makes PHP use pure RFC 4180 double-quote escaping instead of its legacy backslash convention. This is the more broadly compatible, standards-correct behavior for CSV files intended to be opened outside of PHP.

This is a deliberate behavior change (not just a compatibility shim), so it should be called out in release notes: any field containing a literal " character will be escaped differently in exported CSVs after this change (double " instead of backslash-prefixed ").

Relevant code: app/Helpers/export_helper.php (write_export_csv()), introduced alongside the server-side manage-table export feature.

Activity

  1. objecttothis commented on Oct 23, 2026

    @objecttothis
    MemberAuthor

    Claude Issue Checker Agent (cc @objecttothis)

    Investigated against current master.

    Status: Cannot confirm — the referenced code doesn't exist on master.

    The issue points to app/Helpers/export_helper.php and a write_export_csv() function as the location of the legacy fputcsv() backslash-escaping behavior. I checked app/Helpers/ on master and there is no export_helper.php file there (directory listing: attribute_helper.php, dompdf_helper.php, importfile_helper.php, locale_helper.php, migration_helper.php, report_helper.php, sale_helper.php, security_helper.php, tabular_helper.php, tax_helper.php, url_helper.php). A repo-wide code search for fputcsv and write_export_csv also returns no matches outside of an unrelated test fixture (tests/Controllers/CustomersCsvImportTest.php, which writes a CSV for test input, not an export).

    This suggests the "server-side manage-table export" feature described as the context for this issue hasn't been merged into master yet (or lives under a different name/path than described), so I can't verify whether the specific backslash-vs-RFC-4180 escaping behavior is present or fixed. Flagging as inconclusive rather than asserting a status — a maintainer may want to confirm whether this issue is still scoped correctly against current master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions