KimNorgaard / validates_hostname

Extension to ActiveRecord::Base for validating hostnames and domain names
MIT License
38 stars 12 forks source link

Dot at the end of hostname #3

Closed allenwq closed 9 years ago

allenwq commented 9 years ago

'example.org.' the hostname end with dot are considered to be valid now

which should not be valid.. as RFC document says:

RFC952: Note that periods(.) are only allowed when they serve to delimit components of "domain style names".

KimNorgaard commented 9 years ago

This is by design (RFC 1034):

When a user needs to type a domain name, the length of each label is omitted and the labels are separated by dots ("."). Since a complete domain name ends with the root label, this leads to a printed form which ends in a dot. We use this property to distinguish between:

  • a character string which represents a complete domain name (often called "absolute"). For example, "poneria.ISI.EDU."
  • a character string that represents the starting labels of a domain name which is incomplete, and should be completed by local software using knowledge of the local domain (often called "relative"). For example, "poneria" used in the ISI.EDU domain.
allenwq commented 9 years ago

Ok, Thanks !

But name like example.org...... is valid also, Can we provide an option to disable this ?

KimNorgaard commented 9 years ago

Yes, that is not be design :-)

The expected behavior should be that:

1) An option - :allow_root_label (default: false) should be added. This controls wether to check for the presence of a single dot at the end of the domain name. 2) Consecutive dots anywhere in a domain name should never be permitted.

Is this what you are looking for?

allenwq commented 9 years ago

Exactly, If you don't have time I can do this through PR for you :-)

On Mon, Jan 12, 2015 at 10:13 PM, KimNorgaard notifications@github.com wrote:

Yes, that is not be design :-)

The expected behavior should be that:

1) An option - :allow_root_label (default: false) should be added. This controls wether to check for the presence of a single dot at the end of the domain name. 2) Consecutive dots anywhere in a domain name should never be permitted.

Is this what you are looking for?

— Reply to this email directly or view it on GitHub https://github.com/KimNorgaard/validates_hostname/issues/3#issuecomment-69574853 .

KimNorgaard commented 9 years ago

Should be fixed with latest commit. Please confirm that it works in your end.

If it does, I'll bump the version on ruby-gems.

allenwq commented 9 years ago

Many thanks !

I confirm that it works for me, I also tested this option allow_root_label, works fine.