|
@@ -14,6 +14,7 @@ import (
|
|
|
"encoding/base64"
|
|
|
"encoding/json"
|
|
|
gojs "gorunjs/client"
|
|
|
+ "io"
|
|
|
"io/ioutil"
|
|
|
mu "mfw/util"
|
|
|
"net/http"
|
|
@@ -535,19 +536,39 @@ func (s *Script) LoadScript(site *string, code, script_file string, newstate boo
|
|
|
url := S.ToString(-5)
|
|
|
fileName := S.ToString(-6)
|
|
|
ishttps := strings.Contains(url, "https")
|
|
|
- var mycookie []*http.Cookie
|
|
|
- if cookie != "{}" {
|
|
|
- json.Unmarshal([]byte(cookie), &mycookie)
|
|
|
+ //base64匹配
|
|
|
+ base64UrlReg := regexp.MustCompile("data:image")
|
|
|
+ indexArr := base64UrlReg.FindStringIndex(url)
|
|
|
+ name, size, ftype, fid := "", "", "", ""
|
|
|
+ var ret []byte
|
|
|
+ var err error
|
|
|
+ //base64 url
|
|
|
+ if len(indexArr) == 2 { //base64 http://www.mmjyjt.com/data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAqAAAAOwCAYAAAD
|
|
|
+ //截取base64
|
|
|
+ start := indexArr[0]
|
|
|
+ url = url[start:]
|
|
|
+ fileName = "文件下载.jpg"
|
|
|
+ index := strings.Index(url, ",")
|
|
|
+ dec := base64.NewDecoder(base64.StdEncoding, strings.NewReader(url[index+1:]))
|
|
|
+ ret, err = io.ReadAll(dec)
|
|
|
+ if err == nil && len(ret) > 0 {
|
|
|
+ url, name, size, ftype, fid = util.UploadFile(s.SCode, fileName, "", ret)
|
|
|
+ }
|
|
|
} else {
|
|
|
- mycookie = make([]*http.Cookie, 0)
|
|
|
- }
|
|
|
- fileName = strings.TrimSpace(fileName)
|
|
|
- url = strings.TrimSpace(url)
|
|
|
- ret := DownloadFile(s.Downloader, url, method, util.GetTable(param), util.GetTable(head), mycookie, s.Encoding, s.Userproxy, ishttps, s.SCode, s.Timeout)
|
|
|
- url, name, size, ftype, fid := util.UploadFile(s.SCode, fileName, url, ret)
|
|
|
- if strings.TrimSpace(ftype) == "" {
|
|
|
- if len(path.Ext(name)) > 0 {
|
|
|
- ftype = path.Ext(name)[1:]
|
|
|
+ var mycookie []*http.Cookie
|
|
|
+ if cookie != "{}" {
|
|
|
+ json.Unmarshal([]byte(cookie), &mycookie)
|
|
|
+ } else {
|
|
|
+ mycookie = make([]*http.Cookie, 0)
|
|
|
+ }
|
|
|
+ fileName = strings.TrimSpace(fileName)
|
|
|
+ url = strings.TrimSpace(url)
|
|
|
+ ret = DownloadFile(s.Downloader, url, method, util.GetTable(param), util.GetTable(head), mycookie, s.Encoding, s.Userproxy, ishttps, s.SCode, s.Timeout)
|
|
|
+ url, name, size, ftype, fid = util.UploadFile(s.SCode, fileName, url, ret)
|
|
|
+ if strings.TrimSpace(ftype) == "" {
|
|
|
+ if len(path.Ext(name)) > 0 {
|
|
|
+ ftype = path.Ext(name)[1:]
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//特殊处理中国招标投标公共服务平台异常附件过滤
|