At 3/21/02 10:31 PM, Gregory Neil Shapiro wrote:
>A customer complained about the error message he received when trying to
>pre-register a .us domain that wasn't invalid. It told him to 'try
>something similar to "yourname.com"'. Instead of pushing .com, the message
>should probably use the original TLD. Here is a patch:
>
>Index: XML_Client.pm
>===================================================================
>RCS file: /usr/local/src/cvsroot/www/retsiger.com/lib/OpenSRS/XML_Client.pm,v
>retrieving revision 1.1.1.11
>diff -u -u -r1.1.1.11 XML_Client.pm
>--- XML_Client.pm 20 Mar 2002 07:02:26 -0000 1.1.1.11
>+++ XML_Client.pm 22 Mar 2002 06:30:27 -0000
>@@ -897,7 +897,12 @@
> } elsif ($domain !~ /$OPENSRS_TLDS_REGEX$/) {
> return "Top level domain in \"$domain\" is unavailable";
> } elsif ($domain !~
>/^[a-zA-Z0-9][.a-zA-Z0-9\-]*[a-zA-Z0-9]\.name$|^[a-zA-Z0-9][a-zA-Z0-9\-]{1
>,}$OPENSRS_TLDS_REGEX$/) {
>- return "Invalid domain format (try something similar to \"yourname.com\"";
>+ my $tld = "com";
>+ if ($domain =~ /$OPENSRS_TLDS_REGEX$/)
>+ {
>+ $tld = $1;
>+ }
>+ return "Invalid domain format (try something similar to \"yourname$tld\"";
> }
> return undef;
> }
While I'm looking at this, it seems that the line that checks the syntax
of .name domains in the original OpenSRS code is incorrect:
/^[a-zA-Z0-9][.a-zA-Z0-9\-]*[a-zA-Z0-9]\.name$
If this is trying to validate the syntax as either "first.last.name" or
"last.name", it's not quite right. It allows things like
"first...last.name", "first-.last.name", "first.second.third.last.name",
"r.b.name" and "first-first.last.name", all of which are illegal
according to http://www.opensrs.org/dotname_FAQ.shtml.
I think it needs something more like:
/^([a-zA-Z0-9]+\.)?[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9]\.name$
It allows "smith.name", "john.smith.name", "smith-jones.name",
"j.smith.name", "chuck.smith-jones-daminato.name", etc., but not any of
the naughty ones I mentioned above. (It also allows
"john.smith--jones.name" with consecutive hyphens, but the implication on
the page is that this is legal -- it doesn't say it's not, anyway.)
Speaking of that page, I found this statement confusing: "Hyphens are
allowed, but not in the third and fourth character positions." This seems
to literally state that this is legal: "a-b.smith.name" (hyphen is second
character) and this is illegal: "ab-c.smith.name" (hyphen is third
character), but that doesn't seem to make sense. So I took this to mean
"but not in the third and fourth LEVEL" of the domain name (that is,
hyphens are only allowed in the second level -- the last name part). If I
misunderstood, my suggested regexp above is not correct.
--
Robert L Mathews, Tiger Technologies
"The trouble with doing something right the first time is that nobody
appreciates how difficult it was."