Skip to content
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

Merged
merged 1 commit into from
Dec 13, 2015

Conversation

harshavardhana
Copy link
Member

No description provided.

@@ -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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use regex here.

// if string larger than 255 characters return false.
return false
}
if host[(len(host)-1):] == "-" || host[:1] == "-" {
Copy link
Member

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.

return false
}
// host cannot start with a "."
if host[:1] == "." {
Copy link
Member

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.

@harshavardhana
Copy link
Member Author

Cannot end with "." as well.

Domains can end with "." - those are called absolute domains.

@harshavardhana
Copy link
Member Author

Domains can end with "." - those are called absolute domains.

http://www.dns-sd.org/trailingdotsindomainnames.html - for example a request to "https://www.example.com." is as valid as "https://www.example.com"

@harshavardhana
Copy link
Member Author

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.

abperiasamy added a commit that referenced this pull request Dec 13, 2015
endpoint: Validate endpoint properly using isDomainName and isValidIP
@abperiasamy abperiasamy merged commit f759674 into minio:master Dec 13, 2015
@harshavardhana harshavardhana deleted the valid branch December 13, 2015 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants