fix: the CSV round trip keeps values that start with an apostrophe before a formula character (WR-21)
escapeCell left '=x as it was and unescapeCell then dropped its apostrophe on import. A value of apostrophes followed by a formula character now gets one more apostrophe on export, and the import drops exactly one, so unescapeCell is the inverse of escapeCell.
This commit is contained in:
@@ -23,6 +23,9 @@ func TestCSV(t *testing.T) {
|
||||
{"/tab", "/x", "\tlead"},
|
||||
{"/cr", "/x", "\rlead"},
|
||||
{"/ok", "/x", "a=b"},
|
||||
{"/ap", "/x", "'=x"},
|
||||
{"/ap2", "/x", "''-)"},
|
||||
{"/ap3", "/x", "'plain"},
|
||||
}
|
||||
|
||||
t.Run("round trip with each delimiter", func(t *testing.T) {
|
||||
@@ -63,7 +66,7 @@ func TestCSV(t *testing.T) {
|
||||
if lines[1] != "'=1+1" || lines[2] != "'+x" || lines[3] != "'-x" || lines[4] != "'@x" || lines[5] != "a=b" {
|
||||
t.Fatalf("export = %q", lines)
|
||||
}
|
||||
for in, want := range map[string]string{"'=x": "=x", "'+x": "+x", "'abc": "'abc", "''=x": "''=x", "plain": "plain", "'": "'"} {
|
||||
for in, want := range map[string]string{"'=x": "=x", "'+x": "+x", "'abc": "'abc", "''=x": "'=x", "plain": "plain", "'": "'"} {
|
||||
if got := unescapeCell(in); got != want {
|
||||
t.Errorf("unescapeCell(%q) = %q, want %q", in, got, want)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user