aboutsummaryrefslogtreecommitdiff
path: root/plugins/viewhtml/plugin.go
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-02-25 16:13:10 +0100
committerSimon Ser <contact@emersion.fr>2020-02-25 16:13:10 +0100
commitb3f98de1da11e13dea5c08af4f80520258c120cf (patch)
treeb3a4443b307b222fce6c0d40daf4d2032c14002c /plugins/viewhtml/plugin.go
parenta8a3c82579ac244dde56320224f6bd15f17427f7 (diff)
downloadalps-b3f98de1da11e13dea5c08af4f80520258c120cf.tar.gz
alps-b3f98de1da11e13dea5c08af4f80520258c120cf.zip
plugins/viewhtml: add opt-in query param to load remote resources
Loading remote resources by default has privacy implications.
Diffstat (limited to 'plugins/viewhtml/plugin.go')
-rw-r--r--plugins/viewhtml/plugin.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/plugins/viewhtml/plugin.go b/plugins/viewhtml/plugin.go
index b34372f..1007d4a 100644
--- a/plugins/viewhtml/plugin.go
+++ b/plugins/viewhtml/plugin.go
@@ -9,6 +9,7 @@ import (
"strings"
"git.sr.ht/~emersion/koushin"
+ koushinbase "git.sr.ht/~emersion/koushin/plugins/base"
"github.com/labstack/echo/v4"
)
@@ -20,6 +21,17 @@ var (
func init() {
p := koushin.GoPlugin{Name: "viewhtml"}
+ p.Inject("message.html", func(ctx *koushin.Context, _data koushin.RenderData) error {
+ data := _data.(*koushinbase.MessageRenderData)
+ data.Extra["RemoteResourcesAllowed"] = ctx.QueryParam("allow-remote-resources") == "1"
+ hasRemoteResources := false
+ if v := ctx.Get("viewhtml.hasRemoteResources"); v != nil {
+ hasRemoteResources = v.(bool)
+ }
+ data.Extra["HasRemoteResources"] = hasRemoteResources
+ return nil
+ })
+
p.GET("/proxy", func(ctx *koushin.Context) error {
if !proxyEnabled {
return echo.NewHTTPError(http.StatusForbidden, "proxy disabled")