aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2020-05-02 02:26:54 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2020-05-02 02:26:54 +0200
commit3e219c232c0bb4a64f615c599473c959691e6319 (patch)
tree6d061451eaaf828b3cefde33d9b1bafa462268ca /internal
parentff4f709486a69bc1650db73a003255e58cae0532 (diff)
downloadfeed2imap-go-3e219c232c0bb4a64f615c599473c959691e6319.tar.gz
feed2imap-go-3e219c232c0bb4a64f615c599473c959691e6319.tar.bz2
feed2imap-go-3e219c232c0bb4a64f615c599473c959691e6319.zip
Improved image support
Diffstat (limited to 'internal')
-rw-r--r--internal/feed/mail.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/internal/feed/mail.go b/internal/feed/mail.go
index 5f543e4..297aeff 100644
--- a/internal/feed/mail.go
+++ b/internal/feed/mail.go
@@ -14,6 +14,7 @@ import (
"github.com/PuerkitoBio/goquery"
"github.com/emersion/go-message"
"github.com/emersion/go-message/mail"
+ "github.com/gabriel-vasile/mimetype"
"github.com/Necoro/feed2imap-go/internal/feed/template"
"github.com/Necoro/feed2imap-go/pkg/config"
@@ -177,6 +178,10 @@ func (feed *Feed) ToMails(cfg *config.Config) ([]string, error) {
}
func getImage(src string) ([]byte, string) {
+ if strings.HasPrefix(src, "//") {
+ src = "https:" + src
+ }
+
resp, err := stdHTTPClient.Get(src)
if err != nil {
log.Errorf("Error fetching from '%s': %s", src, err)
@@ -190,14 +195,14 @@ func getImage(src string) ([]byte, string) {
return nil, ""
}
+ var mimeStr string
ext := path.Ext(src)
if ext == "" {
- log.Warnf("Cannot determine extension from '%s', skipping.", src)
- return nil, ""
+ mimeStr = mimetype.Detect(img).String()
+ } else {
+ mimeStr = mime.TypeByExtension(ext)
}
-
- mime := mime.TypeByExtension(ext)
- return img, mime
+ return img, mimeStr
}
func cidNr(idx int) string {
d>2-1/+4 Suggested-by: Matthew Richardson <m.richardson@ed.ac.uk> 2014-03-23Heredoc refresh.Jason A. Donenfeld1-43/+45 2014-03-23clip: wait longer for slow systemsJason A. Donenfeld2-2/+2 2014-03-22gpg: allow the use of gpg1 with or without agentJason A. Donenfeld1-10/+15 Suggested-by: Matthieu Weber <mweber@free.fr> 2014-03-22clip: rename SELECTION to X_SELECTIONJason A. Donenfeld2-6/+6 2014-03-22Version bump ahead of release.Jason A. Donenfeld1-1/+1 2014-03-22Makefile: do not use recursion and organizeJason A. Donenfeld12-9/+7 2014-03-22clip: suppress kill errorJason A. Donenfeld2-3/+3 2014-03-22clip: do not race on osxJason A. Donenfeld1-5/+5 2014-03-22clip: use pkill instead of procJason A. Donenfeld1-1/+1 2014-03-20Keepass import should include root-level entriesErik Mackdanz1-0/+1 Repro steps: 1. In KeePass, add some entries as children of the root node 2. Export the KeePass to foo.xml 3. 'keepass2pass.py -f foo.xml' Expect: all entries imported Actual: root-level entries are skipped 2014-03-20keepassx2pass: friendly title fieldPhilip Chase1-1/+24 This patch removes several special characters while attempting to preserve as much meaning in the filename as possible. These changes are made to the KeepassX title before it is used as a file password store filename: - Spaces between words in file names are replaced with camelCasing. - The characters \ | ( ) are each replaced with a hyphen. - Trailing hypens are removed. - @ is replaced with "At" - ' is removed