Skip to content

Commit

Permalink
Addressed issues zmap#171, zmap#186, fixed zmap#189 I hope
Browse files Browse the repository at this point in the history
  • Loading branch information
umbernhard committed Sep 30, 2016
1 parent 531e7bf commit cb40cb0
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions json.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,11 @@ func (c *Certificate) MarshalJSON() ([]byte, error) {
name := c.Subject.CommonName
isValid := false

if len(name) > 2 && name[0] == '*' {
// Check for wildcards and redacts, ignore malformed urls
if len(name) > 2 && name[0] == '*' && name[1] == '.' {
isValid = govalidator.IsURL(name[2:])
} else if len(name) > 2 && name[0] == '?' {
} else if len(name) > 2 && name[0] == '?' && name[1] == '.' {
isValid = isValid || govalidator.IsURL(name[2:])
} else if !strings.Contains(name, ".") {
// If this is just a TLD cert, it's valid
isValid = true
} else {
isValid = govalidator.IsURL(name)
}
Expand All @@ -252,9 +250,10 @@ func (c *Certificate) MarshalJSON() ([]byte, error) {

isValid := false

if len(name) > 2 && name[0] == '*' {
// Check wildcards, redacts, malformed, and tlds
if len(name) > 2 && name[0] == '*' && name[1] == '.' {
isValid = govalidator.IsURL(name[2:])
} else if len(name) > 2 && name[0] == '?' {
} else if len(name) > 2 && name[0] == '?' && name[1] == '.' {
isValid = isValid || govalidator.IsURL(name[2:])
} else if !strings.Contains(name, ".") {
// If this is just a TLD cert, it's valid
Expand Down

0 comments on commit cb40cb0

Please sign in to comment.