Skip to content

Commit

Permalink
Improved input validation
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptTiger committed Sep 11, 2024
1 parent 0663fa2 commit aa391ce
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions hosts-bl.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,10 @@ func deDupe(hbits int) {

// Function to scrub input
func scrubInput(line string, fbhPtr *string, cmts bool) ([]string) {
if strings.ContainsAny(line, " .") && strings.HasPrefix(line, *fbhPtr) {
line = strings.SplitAfterN(line, " ", 2)[1]
if strings.Contains(line, " ") && strings.Contains(line, ".") && strings.HasPrefix(line, *fbhPtr) {
lineSegments := strings.SplitAfterN(line, " ", 2)
if len(lineSegments) != 2 {return nil}
line = lineSegments[1]
if strings.ContainsAny(line, "#") {line = strings.TrimSuffix(strings.SplitAfterN(line, "#", 2)[0], "#")}
line = strings.TrimSpace(line)
if line == "0.0.0.0" {return nil}
Expand Down

0 comments on commit aa391ce

Please sign in to comment.