mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 19:43:49 +08:00
parent
760bb175c7
commit
6d19f07eb4
@ -21,7 +21,6 @@ import (
|
||||
"github.com/Mrs4s/MiraiGo/message"
|
||||
"github.com/Mrs4s/MiraiGo/utils"
|
||||
"github.com/gabriel-vasile/mimetype"
|
||||
"github.com/segmentio/asm/base64"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/tidwall/gjson"
|
||||
|
||||
@ -1118,7 +1117,7 @@ func (bot *CQBot) makeImageOrVideoElem(d map[string]string, video, group bool) (
|
||||
return &LocalImageElement{File: fu.Path}, nil
|
||||
}
|
||||
if strings.HasPrefix(f, "base64") && !video {
|
||||
b, err := base64.StdEncoding.DecodeString(strings.TrimPrefix(f, "base64://"))
|
||||
b, err := global.Base64DecodeString(strings.TrimPrefix(f, "base64://"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/Mrs4s/MiraiGo/utils"
|
||||
"github.com/segmentio/asm/base64"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@ -98,7 +97,7 @@ func FindFile(file, cache, p string) (data []byte, err error) {
|
||||
return nil, err
|
||||
}
|
||||
case strings.HasPrefix(file, "base64"):
|
||||
data, err = base64.StdEncoding.DecodeString(strings.TrimPrefix(file, "base64://"))
|
||||
data, err = Base64DecodeString(strings.TrimPrefix(file, "base64://"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/Mrs4s/MiraiGo/utils"
|
||||
"github.com/segmentio/asm/base64"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
@ -152,3 +154,13 @@ func SplitURL(s string) []string {
|
||||
result = append(result, s[last:])
|
||||
return result
|
||||
}
|
||||
|
||||
// Base64DecodeString decode base64 with avx2
|
||||
// see https://github.com/segmentio/asm/issues/50
|
||||
// avoid incorrect unsafe usage in origin library
|
||||
func Base64DecodeString(s string) ([]byte, error) {
|
||||
e := base64.StdEncoding
|
||||
dst := make([]byte, e.DecodedLen(len(s)))
|
||||
n, err := e.Decode(dst, utils.S2B(s))
|
||||
return dst[:n], err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user