mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
fix: ruleProvider panic
This commit is contained in:
parent
81bef30ae0
commit
c2d1f71305
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user