Skip to content

Commit

Permalink
feat: improve rune scan
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Nov 2, 2021
1 parent 9b123bd commit d73ee04
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/bidichk/bidichk.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ func check(filename string, pos token.Pos, pass *analysis.Pass) error {
for name, r := range disallowedRunes {
start := 0
for {
if !bytes.ContainsRune(body[start:], r) {
idx := bytes.IndexRune(body[start:], r)
if idx == -1 {
break
}
start += bytes.IndexRune(body[start:], r)
start += idx

pass.Reportf(pos+token.Pos(start), "found dangerous unicode character sequence %s", name)

start += utf8.RuneLen(r)
}
}
Expand Down

0 comments on commit d73ee04

Please sign in to comment.