Fix the url regular expression
Chris Herberte - September 4, 2008 - 08:27
| Project: | Whois lookup |
| Version: | 6.x-1.1 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | needs work |
Description
when submitting an IP or example.com.au domain name. everything before .xxx.xxx gets truncated.
submitting example.com.au results in error:
Whois lookup for com.au:
No Data Found
yet /whois/example.com.au works fine
using phpwhois-4.1.3
Any ideas, can anyone confirm this as a bug?

#1
Whoops, I can confirm that this will happen with the url strip-down regexp I'm using in the module. This is actually critical.
#2
I've commented out the regexp in the file whois.module, and it works now.
function whois_parse_url($url) {
//$r = "^(?:(?P\w+)://)?";
//$r .= "(?:(?P\w+):(?P\w+)@)?";
//$r .= "(?P(?:(?P[\w\.]+)\.)?" . "(?P\w+\.(?P\w+)))";
//$r .= "(?::(?P\d+))?";
//$r .= "(?P[\w/]*/(?P\w+(?:\.\w+)?)?)?";
//$r .= "(?:\?(?P[\w=&]+))?";
//$r .= "(?:#(?P\w+))?";
//$r = "!$r!"; // Delimiters
//preg_match($r, $url, $result);
//return $result[6];
return $url;
}
#3
#4
Marked http://drupal.org/node/333050 as a duplicate.
#5
The attached patch expands the regexp to include some multi-level tld's. However this currently requires a list of all these cases, which is hard to maintain.