fix: ruleProvider panic

This commit is contained in:
wwqgtxx 2023-04-14 19:06:25 +08:00
parent 81bef30ae0
commit c2d1f71305

View file

@ -187,6 +187,9 @@ func rulesParse(buf []byte, strategy ruleStrategy, format P.RuleFormat) (any, er
firstLineLength = -1 // don't return ErrNoPayload when read last line firstLineLength = -1 // don't return ErrNoPayload when read last line
str = string(line) str = string(line)
str = strings.TrimSpace(str) str = strings.TrimSpace(str)
if len(str) == 0 {
continue
}
if str[0] == '#' { // comment if str[0] == '#' { // comment
continue continue
} }
@ -194,7 +197,11 @@ func rulesParse(buf []byte, strategy ruleStrategy, format P.RuleFormat) (any, er
continue continue
} }
case P.YamlRule: case P.YamlRule:
if bytes.TrimSpace(line)[0] == '#' { // comment trimLine := bytes.TrimSpace(line)
if len(trimLine) == 0 {
continue
}
if trimLine[0] == '#' { // comment
continue continue
} }
firstLineBuffer.Write(line) firstLineBuffer.Write(line)