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

View File

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