Skip to content

Commit

Permalink
Handles redacted. Fixes zmap#171
Browse files Browse the repository at this point in the history
  • Loading branch information
umbernhard committed Sep 29, 2016
1 parent 16a58a4 commit 4ddb045
Showing 1 changed file with 10 additions and 23 deletions.
33 changes: 10 additions & 23 deletions json.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,13 @@ func (c *Certificate) MarshalJSON() ([]byte, error) {

if len(name) > 2 && name[0] == '*' {
isValid = govalidator.IsURL(name[2:])
} else {
isValid = govalidator.IsURL(name)
}

// If this is just a TLD cert, it's valid
if !strings.Contains(name, ".") {
} else if len(name) > 2 && name[0] == '?' {
isValid = isValid || govalidator.IsURL(name[2:])
} else if !strings.Contains(name, ".") {
// If this is just a TLD cert, it's valid
isValid = true
}

if name[0] == '?' {
isValid = isValid && govalidator.IsURL(name[2:])
} else {
isValid = isValid && govalidator.IsURL(name)
isValid = govalidator.IsURL(name)
}

// Check that this is actually a url and not something else
Expand All @@ -266,22 +260,15 @@ func (c *Certificate) MarshalJSON() ([]byte, error) {

if len(name) > 2 && name[0] == '*' {
isValid = govalidator.IsURL(name[2:])
} else {
isValid = govalidator.IsURL(name)
}

// If this is just a TLD cert, it's valid
if !strings.Contains(name, ".") {
} else if len(name) > 2 && name[0] == '?' {
isValid = isValid || govalidator.IsURL(name[2:])
} else if !strings.Contains(name, ".") {
// If this is just a TLD cert, it's valid
isValid = true
}

if name[0] == '?' {
isValid = isValid && govalidator.IsURL(name[2:])
} else {
isValid = isValid && govalidator.IsURL(name)
isValid = govalidator.IsURL(name)
}

// Check that this is actually a url and not something else
if isValid {
jc.Names = append(jc.Names, name)
}
Expand Down

0 comments on commit 4ddb045

Please sign in to comment.