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

Gurpartap Singh - September 4, 2008 - 12:58
Priority:normal» critical

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

sersim - October 1, 2008 - 16:40

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

Gurpartap Singh - December 4, 2008 - 06:34
Title:Strange Behavior» Fix the url regular expression

#4

Gurpartap Singh - December 4, 2008 - 06:34

Marked http://drupal.org/node/333050 as a duplicate.

#5

helmo - December 4, 2009 - 11:20
Status:active» needs work

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.

AttachmentSize
whois-303833.patch 1.05 KB
 
 

Drupal is a registered trademark of Dries Buytaert.