Browse Source

importers: Fixed panic in mirclike.ParsePost if the post contains no text.

module-madness-pointers 1.2.1
Gisle Aune 6 years ago
parent
commit
1ea04f1577
  1. 6
      internal/importers/mirclike/post.go
  2. 4
      internal/importers/mirclike/post_test.go

6
internal/importers/mirclike/post.go

@ -52,6 +52,9 @@ func ParsePost(line string, date time.Time, prev models.Post) (models.Post, erro
if line[tsEndIndex+2] == '*' {
split := strings.SplitN(line[tsEndIndex+4:], " ", 2)
if len(split) == 1 {
return models.Post{}, ErrNotPost
}
post := models.Post{
ID: "UNASSIGNED",
@ -70,6 +73,9 @@ func ParsePost(line string, date time.Time, prev models.Post) (models.Post, erro
return post, nil
} else if line[tsEndIndex+2] == '<' {
split := strings.SplitN(line[tsEndIndex+2:], " ", 2)
if len(split) == 1 {
return models.Post{}, ErrNotPost
}
post := models.Post{
ID: "UNASSIGNED",

4
internal/importers/mirclike/post_test.go

@ -71,6 +71,10 @@ func TestParsePostErrors(t *testing.T) {
{"[10] <Stuff> Things said.", mirclike.ErrNotPost},
{"[12:34:56:789] <Stuff> Things said.", nil},
{"[12:34:56.789] <Stuff> Things said.", mirclike.ErrNotPost},
{"[12:34] <Stuff>", mirclike.ErrNotPost},
{"[12:34] * Stuff", mirclike.ErrNotPost},
{"[12:34] =Scene=", mirclike.ErrNotPost},
{"[12:34] <=Scene=>", mirclike.ErrNotPost},
}
for i, row := range table {

Loading…
Cancel
Save