mirror of
https://github.com/chainreactors/spray.git
synced 2025-09-15 11:40:13 +00:00
修复bytes类型转换错误的bug
This commit is contained in:
parent
976ce55bdc
commit
fc3f476fe2
@ -505,7 +505,7 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
|
||||
logs.Log.Importantf("Loaded %d dictionaries and %d decorators", len(opt.Dictionaries), len(r.Fns))
|
||||
|
||||
if opt.Match != "" {
|
||||
exp, err := expr.Compile(opt.Match)
|
||||
exp, err := expr.Compile(opt.Match, expr.Patch(&bytesPatcher{}))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -513,7 +513,7 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
|
||||
}
|
||||
|
||||
if opt.Filter != "" {
|
||||
exp, err := expr.Compile(opt.Filter)
|
||||
exp, err := expr.Compile(opt.Filter, expr.Patch(&bytesPatcher{}))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -535,7 +535,7 @@ func (opt *Option) PrepareRunner() (*Runner, error) {
|
||||
}
|
||||
|
||||
if express != "" {
|
||||
exp, err := expr.Compile(express)
|
||||
exp, err := expr.Compile(express, expr.Patch(&bytesPatcher{}))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package internal
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/antonmedv/expr"
|
||||
"github.com/antonmedv/expr/ast"
|
||||
"github.com/antonmedv/expr/vm"
|
||||
"github.com/chainreactors/logs"
|
||||
"github.com/chainreactors/spray/pkg"
|
||||
@ -276,3 +277,18 @@ func MatchWithGlobs(u string, globs []string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type bytesPatcher struct{}
|
||||
|
||||
func (p *bytesPatcher) Visit(node *ast.Node) {
|
||||
switch (*node).(type) {
|
||||
case *ast.MemberNode:
|
||||
ast.Patch(node, &ast.CallNode{
|
||||
Callee: &ast.MemberNode{
|
||||
Node: *node,
|
||||
Name: "String",
|
||||
Property: &ast.StringNode{Value: "String"},
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -105,9 +105,9 @@ type Baseline struct {
|
||||
Url *url.URL `json:"-"`
|
||||
Dir bool `json:"-"`
|
||||
Chunked bool `json:"-"`
|
||||
Body []byte `json:"-"`
|
||||
Header []byte `json:"-"`
|
||||
Raw []byte `json:"-"`
|
||||
Body BS `json:"-"`
|
||||
Header BS `json:"-"`
|
||||
Raw BS `json:"-"`
|
||||
Recu bool `json:"-"`
|
||||
RecuDepth int `json:"-"`
|
||||
URLs []string `json:"-"`
|
||||
|
@ -37,3 +37,9 @@ var ErrMap = map[ErrorType]string{
|
||||
func (e ErrorType) Error() string {
|
||||
return ErrMap[e]
|
||||
}
|
||||
|
||||
type BS []byte
|
||||
|
||||
func (b BS) String() string {
|
||||
return string(b)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user