Prevent multiple newlines being emitted in encoding, newlines added as extra data in decoding

This commit is contained in:
DataHoarder 2023-10-10 08:25:19 +02:00
parent b4e6435498
commit 92d962dcab
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk
2 changed files with 5 additions and 2 deletions

View file

@ -26,7 +26,10 @@ func Decode(data []byte) (stream *Stream, err error) {
}
if d[0] != ':' {
currentRegion.Extra = append(currentRegion.Extra, strings.Trim(d, "\r\n"))
extra := strings.Trim(d, "\r\n")
if len(extra) > 0 {
currentRegion.Extra = append(currentRegion.Extra, extra)
}
continue
}

View file

@ -10,7 +10,7 @@ func Encode(stream *Stream) (hex []byte, err error) {
var entries []string
emitRecord := func(r Record) {
entries = append(entries, r.String()+"\r\n")
entries = append(entries, r.String())
}
emitAddress := func(addr uint32) error {