Archived
1
0

commit which fixes invalid line shit

This commit is contained in:
Jeff Becker 2018-01-04 15:51:26 -05:00
parent aadb4ae230
commit 2752676013
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
2 changed files with 10 additions and 3 deletions

View File

@ -864,7 +864,7 @@ func (self *nntpConnection) handleLine(daemon *NNTPDaemon, code int, line string
//lo, hi, err := daemon.database.GetLastAndFirstForGroup(group)
//if err == nil {
if ValidNewsgroup(group) {
_, _ = io.WriteString(dw, fmt.Sprintf("%s 0 0 y\n", group))
fmt.Fprintf(dw, "%s 0 0 y\n", group)
}
//} else {
// log.Println(self.name, "could not get low/high water mark for", group, err)
@ -996,7 +996,9 @@ func (self *nntpConnection) handleLine(daemon *NNTPDaemon, code int, line string
conn.PrintfLine("215 list of newsgroups follows")
dw := conn.DotWriter()
for _, entry := range list {
io.WriteString(dw, fmt.Sprintf("%s %s %s y\r\n", entry[0], entry[1], entry[2]))
if ValidNewsgroup(entry[0]) {
io.WriteString(dw, fmt.Sprintf("%s %s %s y\r\n", entry[0], entry[1], entry[2]))
}
}
dw.Close()
} else {
@ -1148,7 +1150,9 @@ func (self *nntpConnection) handleLine(daemon *NNTPDaemon, code int, line string
conn.PrintfLine("215 list of newsgroups follows")
dw := conn.DotWriter()
for _, entry := range list {
io.WriteString(dw, fmt.Sprintf("%s %s %s y\r\n", entry[0], entry[1], entry[2]))
if ValidNewsgroup(entry[0]) {
io.WriteString(dw, fmt.Sprintf("%s %s %s y\r\n", entry[0], entry[1], entry[2]))
}
}
dw.Close()
} else {

View File

@ -297,6 +297,9 @@ func decAddr(encaddr, key string) string {
var exp_valid_newsgroup = regexp.MustCompilePOSIX(`^[a-zA-Z0-9.]{1,128}$`)
func newsgroupValidFormat(newsgroup string) bool {
newsgroup = strings.TrimFunc(newsgroup, func(r rune) bool {
return r == ' '
})
return exp_valid_newsgroup.MatchString(newsgroup) && len(newsgroup) > 0
}