From d3abb93cc7a2a61557560543919f2e4c0a1cbd7a Mon Sep 17 00:00:00 2001 From: Cameron Moore Date: Fri, 17 Feb 2017 10:47:21 -0600 Subject: [PATCH] tplimpl: Fix instagram shortcode panic on invalid ID Instagram doesn't return a valid JSON response when the requested ID is invalid or not found. Fixes #3048 --- tpl/tplimpl/template_embedded.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tpl/tplimpl/template_embedded.go b/tpl/tplimpl/template_embedded.go index 50397b28c..abe5937bd 100644 --- a/tpl/tplimpl/template_embedded.go +++ b/tpl/tplimpl/template_embedded.go @@ -60,7 +60,7 @@ func (t *GoHTMLTemplate) EmbedShortcodes() { {{ end }}`) t.AddInternalShortcode("gist.html", ``) t.AddInternalShortcode("tweet.html", `{{ (getJSON "https://api.twitter.com/1/statuses/oembed.json?id=" (index .Params 0)).html | safeHTML }}`) - t.AddInternalShortcode("instagram.html", `{{ if len .Params | eq 2 }}{{ if eq (.Get 1) "hidecaption" }}{{ (getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" (index .Params 0) "/&hidecaption=1").html | safeHTML }}{{ end }}{{ else }}{{ (getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" (index .Params 0) "/&hidecaption=0").html | safeHTML }}{{ end }}`) + t.AddInternalShortcode("instagram.html", `{{ if len .Params | eq 2 }}{{ if eq (.Get 1) "hidecaption" }}{{ with getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" (index .Params 0) "/&hidecaption=1" }}{{ .html | safeHTML }}{{ end }}{{ end }}{{ else }}{{ with getJSON "https://api.instagram.com/oembed/?url=https://instagram.com/p/" (index .Params 0) "/&hidecaption=0" }}{{ .html | safeHTML }}{{ end }}{{ end }}`) } func (t *GoHTMLTemplate) EmbedTemplates() {