]> Sergey Matveev's repositories - sgblog.git/commitdiff
RFC 2047 decode From
authorSergey Matveev <stargrave@stargrave.org>
Wed, 20 May 2020 08:38:14 +0000 (11:38 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 20 May 2020 08:38:14 +0000 (11:38 +0300)
cmd/sgblog-comment-add/main.go

index e74558eca40ce65f4ba52048ff6595af3db0a548..840c3782d0a9a5f3acce3c58cc5f0242d7cff6cb 100644 (file)
@@ -26,6 +26,7 @@ import (
        "fmt"
        "io/ioutil"
        "log"
+       "mime"
        "net/mail"
        "os"
        "os/exec"
@@ -79,6 +80,10 @@ func main() {
        if len(body) == 0 {
                log.Fatal("no body")
        }
+       from, err = new(mime.WordDecoder).DecodeHeader(from)
+       if err != nil {
+               log.Fatal(err)
+       }
 
        subj = strings.TrimPrefix(subj, "Re: ")
        if h, err := hex.DecodeString(subj); err != nil || len(h) != sha1.Size {