fix: danbooru

This commit is contained in:
源文雨 2023-11-19 19:03:28 +09:00
parent 61168adb2e
commit 54c67e30f4

View File

@ -3,6 +3,7 @@ package deepdanbooru
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"image" "image"
"net/url" "net/url"
@ -59,8 +60,12 @@ func tagurl(name, u string) (im image.Image, st *sorttags, err error) {
if err != nil { if err != nil {
return return
} }
if len(data) < 4 {
err = errors.New("data too short")
return
}
tags := make(map[string]float64) tags := make(map[string]float64)
err = json.Unmarshal(data, &tags) err = json.Unmarshal(data[1:len(data)-1], &tags)
if err != nil { if err != nil {
return return
} }