-
Notifications
You must be signed in to change notification settings - Fork 630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
endpoint: Validate endpoint properly using isDomainName and isValidIP #260
Conversation
8960633
to
46e6f9d
Compare
@@ -34,6 +35,63 @@ var maxParts = int64(10000) | |||
// maxPartSize - maximum part size for a single multipart upload operation. | |||
var maxPartSize int64 = 1024 * 1024 * 1024 * 5 | |||
|
|||
// isDomainName validates input string if it conforms with | |||
// RFC 1035 and RFC 3696 for domain standards. | |||
func isDomainName(host string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use regex here.
e06f253
to
39f333f
Compare
// if string larger than 255 characters return false. | ||
return false | ||
} | ||
if host[(len(host)-1):] == "-" || host[:1] == "-" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on RFC, this gets very complicated. Also they keep expanding the rules. We are better of doing some minimal regex rules to eliminate invalid domain names for known cases and let others pass through. This can be a series of regex checks to keep it readable.
7ce039c
to
0367ca6
Compare
return false | ||
} | ||
// host cannot start with a "." | ||
if host[:1] == "." { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot end with "." as well.
Domains can end with "." - those are called absolute domains. |
0367ca6
to
666e8e2
Compare
http://www.dns-sd.org/trailingdotsindomainnames.html - for example a request to "https://www.example.com." is as valid as "https://www.example.com" |
You are right since this will be for our purposes, i do not see we need to be Browser like generic in validating domain names. |
666e8e2
to
7415c56
Compare
7415c56
to
09482ac
Compare
endpoint: Validate endpoint properly using isDomainName and isValidIP
No description provided.