diff --git a/contrib/backends/srndv2/src/srnd/frontend_http.go b/contrib/backends/srndv2/src/srnd/frontend_http.go index 9f2e661..0dafd1a 100644 --- a/contrib/backends/srndv2/src/srnd/frontend_http.go +++ b/contrib/backends/srndv2/src/srnd/frontend_http.go @@ -743,7 +743,7 @@ func (self *httpFrontend) handle_postRequest(pr *postRequest, b bannedFunc, e er } ref := pr.Reference - if len(ref) > 0 { + if ref != "" { if ValidMessageID(ref) { if self.daemon.database.HasArticleLocal(ref) { nntp.headers.Set("References", ref) @@ -796,7 +796,7 @@ func (self *httpFrontend) handle_postRequest(pr *postRequest, b bannedFunc, e er } nntp.headers.Set("Subject", safeHeader(subject)) - if isSage(subject) { + if isSage(subject) && ref != "" { nntp.headers.Set("X-Sage", "1") } @@ -821,7 +821,7 @@ func (self *httpFrontend) handle_postRequest(pr *postRequest, b bannedFunc, e er msgid = genMessageID(pr.Frontend) } - nntp.headers.Set("From", formatAddress(safeHeader(name), "poster@" + pr.Frontend)) + nntp.headers.Set("From", formatAddress(safeHeader(name), "poster@"+pr.Frontend)) nntp.headers.Set("Message-ID", msgid) // set message @@ -834,7 +834,21 @@ func (self *httpFrontend) handle_postRequest(pr *postRequest, b bannedFunc, e er } if len(cites) > 0 { - nntp.headers.Set("Reply-To", strings.Join(cites, " ")) + if ref == "" && len(cites) == 1 { + /* + this is workaround for: + + {RFC 5322} + If the parent message does not contain + a "References:" field but does have an "In-Reply-To:" field + containing a single message identifier, then the "References:" field + will contain the contents of the parent's "In-Reply-To:" field + followed by the contents of the parent's "Message-ID:" field (if + any). + */ + cites = append(cites, "<0>") + } + nntp.headers.Set("In-Reply-To", strings.Join(cites, " ")) } // set date diff --git a/contrib/backends/srndv2/src/srnd/util.go b/contrib/backends/srndv2/src/srnd/util.go index 5cdcf44..cd0f8eb 100644 --- a/contrib/backends/srndv2/src/srnd/util.go +++ b/contrib/backends/srndv2/src/srnd/util.go @@ -92,6 +92,10 @@ func ValidMessageID(id string) bool { strings.IndexAny(id[1:len(id)-1], "/\\") < 0 } +func ReservedMessageID(id string) bool { + return id == "<0>" || id == "" +} + // message id hash func HashMessageID(msgid string) string { return fmt.Sprintf("%x", sha1.Sum([]byte(msgid))) @@ -898,7 +902,7 @@ func storeMessage(daemon *NNTPDaemon, hdr textproto.MIMEHeader, body io.Reader) log.Println("dropping message with invalid mime header, no message-id") _, err = io.Copy(Discard, body) return - } else if ValidMessageID(msgid) { + } else if ValidMessageID(msgid) && !ReservedMessageID(msgid) { f = daemon.store.CreateFile(msgid) } else { // invalid message-id @@ -914,9 +918,9 @@ func storeMessage(daemon *NNTPDaemon, hdr textproto.MIMEHeader, body io.Reader) } // ask for replies - replyTos := strings.Split(hdr.Get("Reply-To"), " ") + replyTos := strings.Split(hdr.Get("In-Reply-To"), " ") for _, reply := range replyTos { - if ValidMessageID(reply) { + if ValidMessageID(reply) && !ReservedMessageID(reply) { if !daemon.store.HasArticle(reply) { go daemon.askForArticle(reply) }