Archived
1
0

srnd: custom email address formatter, some tweaks

This adds custom email address formatter, which, unlike stdlib one, doesn't needlessly quote names.
Quoted names can be a bit of issue with older nodes which parse addresses in simpler way, and end up not removing quote characters.
This also ensures that newlines cannot be inserted in in From and Subject headers, which effectively allowed insertion of new headers in message being posted, and generating invalid messages.
This commit is contained in:
cathugger
2018-12-12 18:38:58 +02:00
parent 2ac773cc64
commit 40e4ae1fc4
3 changed files with 129 additions and 27 deletions

View File

@@ -156,10 +156,7 @@ func newPlaintextArticle(message, email, subject, name, instance, message_id, ne
nntp := &nntpArticle{
headers: make(ArticleHeaders),
}
nntp.headers.Set("From", (&mail.Address{
Name: name,
Address: email,
}).String())
nntp.headers.Set("From", formatAddress(name, email))
nntp.headers.Set("Subject", subject)
if isSage(subject) {
nntp.headers.Set("X-Sage", "1")