{"action":"created","issue":{"url":"https://api.github.com/repos/zendframework/zf2/issues/7312","labels_url":"https://api.github.com/repos/zendframework/zf2/issues/7312/labels{/name}","comments_url":"https://api.github.com/repos/zendframework/zf2/issues/7312/comments","events_url":"https://api.github.com/repos/zendframework/zf2/issues/7312/events","html_url":"https://github.com/zendframework/zf2/issues/7312","id":60688270,"number":7312,"title":"[ZF3][RFC] Refactoring the Hostname validator","user":{"login":"moderndeveloperllc","id":1920405,"avatar_url":"https://avatars.githubusercontent.com/u/1920405?v=3","gravatar_id":"","url":"https://api.github.com/users/moderndeveloperllc","html_url":"https://github.com/moderndeveloperllc","followers_url":"https://api.github.com/users/moderndeveloperllc/followers","following_url":"https://api.github.com/users/moderndeveloperllc/following{/other_user}","gists_url":"https://api.github.com/users/moderndeveloperllc/gists{/gist_id}","starred_url":"https://api.github.com/users/moderndeveloperllc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moderndeveloperllc/subscriptions","organizations_url":"https://api.github.com/users/moderndeveloperllc/orgs","repos_url":"https://api.github.com/users/moderndeveloperllc/repos","events_url":"https://api.github.com/users/moderndeveloperllc/events{/privacy}","received_events_url":"https://api.github.com/users/moderndeveloperllc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-11T16:40:18Z","updated_at":"2015-03-11T16:43:00Z","closed_at":null,"body":"It looks like I may have time available to do a long needed refactoring of the Hostname validator. I would like feedback from the core contributors when it comes to the desirability of certain options.\r\n\r\n### Why is a refactoring needed? ###\r\n* Length and positional validations are currently being done on the composed Unicode encoding of domains and TLDs. All length requirements are based on the ACE of the name.\r\n* Not nearly enough IDN domain info. There are [many, many more](http://www.iana.org/domains/idn-tables) domain tables. This brings into question the current system for storing this info.\r\n* The class currently assumes PCRE Unicode support without testing for it.\r\n* There is currently a homegrown function that replicates `idn_to_utf8()` functionality, but none for `idn_to_ascii()`.\r\n* There is no way to specify a language restriction for a TLD (Only check Icelandic characters for this .com domain)\r\n* There is no option to see if the hostname actually _exists_ via something like `checkdnsrr()`.\r\n\r\n#### I propose that this validator either: ####\r\n  a) Me moved over to the `Zend\\I18n\\Validator` namespace so we can be assured of the `intl` extension.\r\n  b) Split the class - Have a non-IDN version in `Zend\\Validator` for use by developers who don't deal with IDN domains, and a version in `Zend\\I18n\\Validator` that includes all the IDN files, manipulation, etc.\r\nor\r\n  c) Write `intl`-checking logic into a class in `Zend\\Validator`. If we don't have that or PCRE Unicode support, only check non-IDN domains and characters.\r\n\r\nThe first option has the value of being DRY'er by not replicating much of the same code. With ZF3 trying to remove inter-module dependancies, I'm not sure you would want to add `Zend\\Validator` as a requirement to the `Zend\\I18n` module. The second option would probably result in faster code for a majority of users by not including lots of logic and data for every domain check. For instance, if no language is specified, you could be checking upwards of 100 character sets for domains in the .com TLD. The third option would have code that is a bit more complex, and and you are bringing `Zend\\I18n\\Validator`-type functions into the `Zend\\Validator` namespace.\r\n\r\nThe downside of option a) is that there is now another module to add (Zend\\I18n) for any dev who wants to check hostnames - even if they are not doing any I18n. The issue with b) is that it isn't DRY, and will require more maintenance, testing, etc.\r\n\r\n### Questions for Core Developers ###\r\n- [ ] Are these valid reasons to take the time and rewrite everything, or is the current class structure fine?\r\n- [ ] Do I split the Hostname validation code into two classes, move it into `Zend\\I18n\\Validator`, or try and write `intl`-checking logic into a class in `Zend\\Validator`?\r\n- [ ] Would you want a separate HostnameExists class for `checkdnsrr()`-style checking, or as an option to the `Hostname` class?\r\n- [ ] Any thoughts on data storage? I know that loading files from the harddrive is slow, but I don't think we can realistically stuff this class with the > 1MB of data that all these code tables contain.\r\n\r\n### TODOs: ###\r\n- [ ] Decide to split or not split the class\r\n- [ ] Figure out how to store IDN information\r\n- [ ] Write tests\r\n- [ ] Code the validation logic for the class (or two!)\r\n- [ ] Add (optional) caching logic for data files.\r\n- [ ] Add new `Zend\\Validator\\HostnameExists` class to check for existing records?"},"comment":{"url":"https://api.github.com/repos/zendframework/zf2/issues/comments/78302624","html_url":"https://github.com/zendframework/zf2/issues/7312#issuecomment-78302624","issue_url":"https://api.github.com/repos/zendframework/zf2/issues/7312","id":78302624,"user":{"login":"moderndeveloperllc","id":1920405,"avatar_url":"https://avatars.githubusercontent.com/u/1920405?v=3","gravatar_id":"","url":"https://api.github.com/users/moderndeveloperllc","html_url":"https://github.com/moderndeveloperllc","followers_url":"https://api.github.com/users/moderndeveloperllc/followers","following_url":"https://api.github.com/users/moderndeveloperllc/following{/other_user}","gists_url":"https://api.github.com/users/moderndeveloperllc/gists{/gist_id}","starred_url":"https://api.github.com/users/moderndeveloperllc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moderndeveloperllc/subscriptions","organizations_url":"https://api.github.com/users/moderndeveloperllc/orgs","repos_url":"https://api.github.com/users/moderndeveloperllc/repos","events_url":"https://api.github.com/users/moderndeveloperllc/events{/privacy}","received_events_url":"https://api.github.com/users/moderndeveloperllc/received_events","type":"User","site_admin":false},"created_at":"2015-03-11T16:43:00Z","updated_at":"2015-03-11T16:43:00Z","body":"ping @DASPRiD, @Ocramius"}}