v2.6.1 (#169)
1、新增垃圾邮件过滤插件 2、使用使用github.com/dlclark/regexp2替换go原生的正则包 3、修复空数据导致的邮件插入失败
This commit is contained in:
1 parent
9ffbdf41c3
commit
054336fe9e
78 files changed
+1123
-329
No files matched your search
@@ -1,10 +1,10 @@
|
||||
package match
|
||||
|
||||
import (
|
||||
"github.com/Jinnrry/pmail/dto/parsemail"
|
||||
"github.com/Jinnrry/pmail/utils/context"
|
||||
"github.com/dlclark/regexp2"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"pmail/dto/parsemail"
|
||||
"pmail/utils/context"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
type RegexMatch struct {
|
||||
@@ -21,8 +21,8 @@ func NewRegexMatch(field, rule string) *RegexMatch {
|
||||
|
||||
func (r *RegexMatch) Match(ctx *context.Context, email *parsemail.Email) bool {
|
||||
content := getFieldContent(r.Field, email)
|
||||
|
||||
match, err := regexp.MatchString(r.Rule, content)
|
||||
re := regexp2.MustCompile(r.Rule, 0)
|
||||
match, err := re.MatchString(content)
|
||||
|
||||
if err != nil {
|
||||
log.WithContext(ctx).Errorf("rule regex error %v", err)
|
||||
|
||||
Reference in new issue
Block a user