xwp / stream

🗄️ Stream plugin for WordPress
https://wordpress.org/plugins/stream/
GNU General Public License v2.0
405 stars 119 forks source link

CSV export is malformed when any value contains a comma #1416

Open johnbillion opened 1 year ago

johnbillion commented 1 year ago

Bug Report

Expected Behavior

When exporting logs as a CSV, all data should be well-formed.

Actual Behavior

When any field value contains a comma, the CSV is malformed.

Steps to Reproduce the Problem

  1. Set your user display name to one that contains a comma, for example "Last Name, First Name"
  2. Perform an action that gets logged in the audit log
  3. Visit the audit log screen and download a CSV from the Record Actions menu at the bottom
  4. Open the CSV in a spreadsheet application which will show the data in columns
  5. Observe that the CSV output for the affected row is malformed due to the unquoted comma

Suggested Fix

The Exporter_CSV::output_file() method should use fputcsv() instead of manually concatenating fields with commas.

System Information