aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--go.mod1
-rw-r--r--go.sum2
-rw-r--r--internal/feed/mail.go15
4 files changed, 14 insertions, 5 deletions
diff --git a/README.md b/README.md
index b0d41cf..bda5ce2 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,7 @@ for details.
(feature contained also in [fork of the original][nec])
* Fix `include-images` option: It now includes images as mime-parts. An additional `embed-images` option serves the images
as inline base64-encoded data (the old default behavior of feed2imap).
+* Improved image inclusion: Links without scheme; images without extension (using mime-detection)
* Use HTML-Parser instead of regular expressions for modifying the HTML content.
### Subtle differences
diff --git a/go.mod b/go.mod
index f4dfdcb..0cd0ffb 100644
--- a/go.mod
+++ b/go.mod
@@ -6,6 +6,7 @@ require (
github.com/PuerkitoBio/goquery v1.5.0
github.com/emersion/go-imap v1.0.4
github.com/emersion/go-message v0.11.3-0.20200422153910-8c6ac6b57e3d
+ github.com/gabriel-vasile/mimetype v1.1.0
github.com/google/go-cmp v0.4.0
github.com/mmcdole/gofeed v1.0.0-beta2.0.20200331235650-4298e4366be3
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
diff --git a/go.sum b/go.sum
index 6c11df4..2731160 100644
--- a/go.sum
+++ b/go.sum
@@ -15,6 +15,8 @@ github.com/emersion/go-sasl v0.0.0-20191210011802-430746ea8b9b h1:uhWtEWBHgop1rq
github.com/emersion/go-sasl v0.0.0-20191210011802-430746ea8b9b/go.mod h1:G/dpzLu16WtQpBfQ/z3LYiYJn3ZhKSGWn83fyoyQe/k=
github.com/emersion/go-textwrapper v0.0.0-20160606182133-d0e65e56babe h1:40SWqY0zE3qCi6ZrtTf5OUdNm5lDnGnjRSq9GgmeTrg=
github.com/emersion/go-textwrapper v0.0.0-20160606182133-d0e65e56babe/go.mod h1:aqO8z8wPrjkscevZJFVE1wXJrLpC5LtJG7fqLOsPb2U=
+github.com/gabriel-vasile/mimetype v1.1.0 h1:+ahX+MvQPFve4kO9Qjjxf3j49i0ACdV236kJlOCRAnU=
+github.com/gabriel-vasile/mimetype v1.1.0/go.mod h1:6CDPel/o/3/s4+bp6kIbsWATq8pmgOisOPG40CJa6To=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/martinlindhe/base36 v1.0.0 h1:eYsumTah144C0A8P1T/AVSUk5ZoLnhfYFM3OGQxB52A=
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 {
>2008-07-04Added ability to install missing plugin depsRené 'Necoro' Neumann3-95/+126 2008-07-04Fixed find_best_match for <portage-2.1.5René 'Necoro' Neumann1-2/+2 2008-07-04Some more dependency awarenessRené 'Necoro' Neumann5-23/+59 2008-07-03Some window refinementRené 'Necoro' Neumann1-109/+126 2008-07-03Removed XSD_LOCATION -- as there is no more xsd ;)René 'Necoro' Neumann2-5/+1 2008-07-03Updated setup.py to install the correct set of pluginsRené 'Necoro' Neumann1-3/+2 2008-07-03Ported etc-proposals pluginRené 'Necoro' Neumann3-50/+43 2008-07-03Ported gpytage pluginRené 'Necoro' Neumann2-16/+14 2008-07-03Ported Notify pluginRené 'Necoro' Neumann4-37/+51 2008-07-03Remove xsd and -x cmdline optionRené 'Necoro' Neumann2-107/+1 2008-07-03Ported completelyRené 'Necoro' Neumann3-548/+54 2008-07-03Should show dependencies nowRené 'Necoro' Neumann2-82/+128 2008-07-03Use __slots__ for the PkgData class to save memoryRené 'Necoro' Neumann1-2/+3 2008-07-03New plugin system - first hackRené 'Necoro' Neumann2-420/+683 2008-06-30Now the new design is able to do the same as the old oneRené 'Necoro' Neumann3-168/+182 2008-06-30First draft of the new plugin windowRené 'Necoro' Neumann1-8/+172 2008-06-30Added stuff to plugin.pyRené 'Necoro' Neumann1-2/+24 2008-06-30Beautified some dialogsRené 'Necoro' Neumann1-6/+8 2008-06-30Only add a package to mergequeue if everything went fineRené 'Necoro' Neumann1-1/+1 2008-06-26Removed '__find_resolved_unresolved' as it is quite useless.René 'Necoro' Neumann3-53/+29 2008-06-26Added very basic set queryingRené 'Necoro' Neumann3-0/+27 2008-06-25Now load 22 versions when running the correct portageRené 'Necoro' Neumann4-8/+18 2008-06-25Added Package_22 and System_22René 'Necoro' Neumann4-5/+63