Skip to content

Commit

Permalink
decoding: catch bad tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
ionous committed Apr 7, 2024
1 parent e39ee34 commit 1c0df51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions decode/bug_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package decode_test

import (
"errors"
"testing"

"github.com/ionous/tell/collect/imap"
Expand Down Expand Up @@ -33,3 +34,12 @@ func TestBug(t *testing.T) {
- "other"`,
)
}

// verify that an erroneous tab is caught
func TestTabCatching(t *testing.T) {
var badTab = "- - \"First\"\n\t- \"Second\""
test(t,
"bad tab",
errors.New("tabs are invalid"),
badTab)
}
2 changes: 2 additions & 0 deletions token/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func (n *tokenizer) tokenize() charm.State {
return charm.Statement("tokenize", func(q rune) (ret charm.State) {
n.start = n.curr
switch q {
case runes.HTab:
ret = charm.Error(errors.New("tabs are invalid whitespace"))
case runes.Hash:
next := n.commentDecoder()
ret = send(next, q)
Expand Down

0 comments on commit 1c0df51

Please sign in to comment.