The file seeds for the streaming reader hold wrapping, borders, row
heights and merges, written and by hand (valid and not), so FuzzRead
checks them against reading the whole file. Fuzzing found the streaming
reader taking a key with no value ("sheets":,) as absent where
encoding/json refuses the file; now it refuses it too, and the case is
kept as a seed. A number with a style that wraps or draws borders is
read the general way, so the rows it shapes are indexed.- commit
- 7631e49272a4300b9af7f7bd4c36af37ec57207d
- parent
- 39374af3c3cc4ea1e6637906008f1279dde65784
- author
- Dami <dami.etoile@gmail.com>
- kind
- fix risk score 1.4 of 3, Jev's estimate
| M | internal/ | 3 | +++ |
| M | internal/ | 9 | +++++++++ |
| A | internal/ | 2 | ++ |
@@ -243,6 +243,9 @@ func (sc *scanner) raw() (json.RawMessage, error) {
243243 }244244 switch c {245245 case ',', '}', ']', ' ', '\t', '\n', '\r':246+ if len(out) == 0 { // a key without its value: "sheets":,247+ return nil, syntax(c, "a value")248+ }246249 return out, sc.r.UnreadByte()247250 }248251 out = append(out, c)@@ -187,6 +187,12 @@ func streamSeeds(t testing.TB) [][]byte {
187187 s.SetStyle(NewRect(Addr{Row: 11}, Addr{Col: 3, Row: 11}), func(st *Style) { st.Bold = true })188188 s.SetNote(Addr{Col: 5, Row: 1}, "a note")189189 s.SetColWidth(1, 20)190+ s.SetStyle(NewRect(Addr{Row: 4}, Addr{Row: 4}), func(st *Style) { st.Wrap = WrapOn })191+ s.SetStyle(NewRect(Addr{Col: 4}, Addr{Col: 4, Row: MaxRows - 1}), func(st *Style) { st.Wrap = WrapClip })192+ s.SetBorders(NewRect(Addr{Row: 1}, Addr{Col: 2, Row: 3}), BorderAll, LineThin)193+ s.SetBorders(NewRect(Addr{Row: 1}, Addr{Col: 2, Row: 3}), BorderOuter, LineDouble)194+ s.SetRowHeight(6, 7, 3)195+ s.LoadMerge(NewRect(Addr{Col: 6}, Addr{Col: 8, Row: 1}))190196 one := []byte(written(t, s.Book()))191197 if _, err := s.Book().AddSheet("Other", 1); err != nil {192198 t.Fatal(err)@@ -211,6 +217,9 @@ func streamSeeds(t testing.TB) [][]byte {
211217 []byte(`{"version": 4, "cells": "x", "sheets": []}`),212218 []byte(`{"version": 2, "cells": {"A1": "😀", "A2": "bad \xff", "ZZ9": 5}}`),213219 []byte(`{"version": 2, "cells": {"A1": "1"}} trailing`),220+ []byte(`{"version": 2, "heights": {"2": 3, "9": 99}, "merges": ["A1:B1", "B1:C2", "D4"], "cells": {"A1": {"input": "5", "wrap": "wrap", "borders": {"top": "thin", "right": "double"}}}}`),221+ []byte(`{"version": 2, "cells": {"A1": {"input": "x", "wrap": "sideways"}, "B1": {"borders": {"left": "dotted"}}}}`),222+ []byte(`{"version": 2, "heights": {"0": 2}, "merges": ["A1:"], "cells": {}}`),214223 []byte(`null`), []byte(`[]`), []byte(`{"version": 2, "cells": {"A1": "1",}}`), []byte(`{"version": 2, "cells": {"A1"`),215224 }216225 }