add check for short posts
This commit is contained in:
parent
5ea16f369a
commit
d5e0f7d698
@ -680,6 +680,13 @@ func (self *httpFrontend) handle_postRequest(pr *postRequest, b bannedFunc, e er
|
|||||||
e(err)
|
e(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !hasAtLeastNWords(m, 3) {
|
||||||
|
err = errors.New("your message is too short")
|
||||||
|
e(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
nntp := new(nntpArticle)
|
nntp := new(nntpArticle)
|
||||||
defer nntp.Reset()
|
defer nntp.Reset()
|
||||||
var banned bool
|
var banned bool
|
||||||
|
@ -800,3 +800,9 @@ func storeMessage(daemon *NNTPDaemon, hdr textproto.MIMEHeader, body io.Reader)
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func hasAtLeastNWords(str string, n int) bool {
|
||||||
|
parts := strings.Split(str, " ")
|
||||||
|
return len(parts) > n
|
||||||
|
}
|
Reference in New Issue
Block a user