mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-24 10:57:06 +00:00
dsl replacement function extended with regex support
This commit is contained in:
parent
6ef172e046
commit
9d1d2bfe16
@ -12,7 +12,7 @@ import (
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
|
||||
"github.com/Knetic/govaluate"
|
||||
)
|
||||
|
||||
@ -39,7 +39,11 @@ func HelperFunctions() (functions map[string]govaluate.ExpressionFunction) {
|
||||
}
|
||||
|
||||
functions["replace"] = func(args ...interface{}) (interface{}, error) {
|
||||
return strings.ReplaceAll(args[0].(string), args[1].(string), args[2].(string)), nil
|
||||
compiled, err := regexp.Compile(args[1].(string))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return compiled.ReplaceAllString(args[0].(string), args[2].(string)), nil
|
||||
}
|
||||
|
||||
functions["trim"] = func(args ...interface{}) (interface{}, error) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user