From 54c67e30f4a017fb590b617ae466ed26775147a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 19 Nov 2023 19:03:28 +0900 Subject: [PATCH] fix: danbooru --- plugin/danbooru/tag.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugin/danbooru/tag.go b/plugin/danbooru/tag.go index 7df56492..0e29c70e 100644 --- a/plugin/danbooru/tag.go +++ b/plugin/danbooru/tag.go @@ -3,6 +3,7 @@ package deepdanbooru import ( "bytes" "encoding/json" + "errors" "fmt" "image" "net/url" @@ -59,8 +60,12 @@ func tagurl(name, u string) (im image.Image, st *sorttags, err error) { if err != nil { return } + if len(data) < 4 { + err = errors.New("data too short") + return + } tags := make(map[string]float64) - err = json.Unmarshal(data, &tags) + err = json.Unmarshal(data[1:len(data)-1], &tags) if err != nil { return }