Write log export CSV rows with safecsv WriteRow
Document that Write and WriteRow sanitize fields; export streaming uses WriteRow at call sites instead of Write([]string). Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Bryan FRIMIN <bryan@frimin.fr>
This commit is contained in:
@@ -41,12 +41,16 @@ func NewWriter(w io.Writer) *Writer {
|
||||
return &Writer{inner: csv.NewWriter(w)}
|
||||
}
|
||||
|
||||
// Write encodes a CSV record after sanitizing every field. Prefer WriteRow for
|
||||
// literal column values at call sites.
|
||||
func (w *Writer) Write(record []string) error {
|
||||
return w.inner.Write(SanitizeRecord(record))
|
||||
}
|
||||
|
||||
// WriteRow encodes one CSV record from fields, sanitizing each value before
|
||||
// encoding (spreadsheet formula injection mitigation).
|
||||
func (w *Writer) WriteRow(fields ...string) error {
|
||||
return w.Write(fields)
|
||||
return w.inner.Write(SanitizeRecord(fields))
|
||||
}
|
||||
|
||||
func (w *Writer) Flush() {
|
||||
|
||||
Reference in New Issue
Block a user