添加无效curl字符串判断
This commit is contained in:
parent
1075b5bbaf
commit
0b50b2f541
15
config.go
15
config.go
|
@ -182,7 +182,10 @@ func parseCurl(curl string) []string {
|
||||||
|
|
||||||
curldata, err := ioutil.ReadAll(curlfile)
|
curldata, err := ioutil.ReadAll(curlfile)
|
||||||
for _, curlinfo := range strings.Split(string(curldata), "\n") {
|
for _, curlinfo := range strings.Split(string(curldata), "\n") {
|
||||||
result = append(result, strings.Trim(curlinfo, "\r\n "))
|
curlstr := strings.Trim(curlinfo, "\r\n ")
|
||||||
|
if len(curlstr) >= 4 {
|
||||||
|
result = append(result, curlstr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case '#':
|
case '#':
|
||||||
|
@ -195,10 +198,16 @@ func parseCurl(curl string) []string {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
for _, curlinfo := range strings.Split(string(curldata), "\n") {
|
for _, curlinfo := range strings.Split(string(curldata), "\n") {
|
||||||
result = append(result, strings.Trim(curlinfo, "\r\n "))
|
curlstr := strings.Trim(curlinfo, "\r\n ")
|
||||||
|
if len(curlstr) >= 4 {
|
||||||
|
result = append(result, curlstr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
result = append(result, strings.Trim(curl, "\r\n "))
|
curlstr := strings.Trim(curl, "\r\n ")
|
||||||
|
if len(curlstr) >= 4 {
|
||||||
|
result = append(result, curlstr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -10,12 +10,9 @@ import (
|
||||||
func TestExecute(t *testing.T) {
|
func TestExecute(t *testing.T) {
|
||||||
curl := `curl 'https://appgrowing.cn/' -H 'authority: appgrowing.cn' -H 'cache-control: max-age=0' -H 'upgrade-insecure-requests: 1' -H 'user-agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: zh' -H 'cookie: _ga=GA1.2.1371058419.1533104518; _gid=GA1.2.896241740.1543307916; _gat_gtag_UA_4002880_19=1' -H 'if-none-match: W/"5bf7a0a9-ca6"' -H 'if-modified-since: Fri, 23 Nov 2018 06:39:37 GMT' --compressed`
|
curl := `curl 'https://appgrowing.cn/' -H 'authority: appgrowing.cn' -H 'cache-control: max-age=0' -H 'upgrade-insecure-requests: 1' -H 'user-agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: zh' -H 'cookie: _ga=GA1.2.1371058419.1533104518; _gid=GA1.2.896241740.1543307916; _gat_gtag_UA_4002880_19=1' -H 'if-none-match: W/"5bf7a0a9-ca6"' -H 'if-modified-since: Fri, 23 Nov 2018 06:39:37 GMT' --compressed`
|
||||||
|
|
||||||
u, err := curl2info.ParseRawCURL(curl)
|
u := curl2info.ParseRawCURL(curl)
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = u.CreateWorkflow(nil).Execute()
|
_, err := u.CreateWorkflow(nil).Execute()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("TestExecute")
|
t.Error("TestExecute")
|
||||||
}
|
}
|
||||||
|
@ -41,7 +38,6 @@ func TestExecutePlan(t *testing.T) {
|
||||||
person := NewPerson()
|
person := NewPerson()
|
||||||
person.Config("test.yaml")
|
person.Config("test.yaml")
|
||||||
person.Execute()
|
person.Execute()
|
||||||
|
|
||||||
// for _, task := range person.Tasks.GetLoopValues() {
|
// for _, task := range person.Tasks.GetLoopValues() {
|
||||||
// task.GetValue().(*Task).ExecuteOnPlan()
|
// task.GetValue().(*Task).ExecuteOnPlan()
|
||||||
// }
|
// }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user