Drop redundant safecsv WriteRow helper
WriteRow was a variadic alias for Write(SanitizeRecord(...)) with no extra safety or column checks. Export call sites already use []string headers; matching encoding/csv keeps one API surface. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Bryan FRIMIN <bryan@frimin.fr>
This commit is contained in:
@@ -50,7 +50,7 @@ func TestWriterWrite(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
|
||||
w := NewWriter(&buf)
|
||||
require.NoError(t, w.WriteRow("ok", "=evil"))
|
||||
require.NoError(t, w.Write([]string{"ok", "=evil"}))
|
||||
w.Flush()
|
||||
require.NoError(t, w.Error())
|
||||
|
||||
|
||||
@@ -41,18 +41,11 @@ 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.
|
||||
// Write encodes a CSV record after sanitizing every field.
|
||||
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.inner.Write(SanitizeRecord(fields))
|
||||
}
|
||||
|
||||
func (w *Writer) Flush() {
|
||||
w.inner.Flush()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user