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

This commit is contained in:
2019-01-05 10:33:50 +01:00
parent 17fd3c60f8
commit 1ea04f1577
2 changed files with 10 additions and 0 deletions
+6
View File
@@ -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
View File
@@ -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 {