IP Address validation

Features wanted...
grsychckn
Posts: 16
Joined: 28 Dec 2010 16:24

Re: IP Address validation

Post by grsychckn »

PeterH wrote:OK: first question is: address or name.
If it's an address it could be checked if correct.

Bad, if a non-correct address would mean it's a name...
In fact, there could be an option to enable to validate address before resolution. If not checked, performs the same as existing. If checked, tries to determine if address starts with IP address (whatever criteria). If determined to be an IP address, warns the user before continuing if it fails to validate the address. In this case, the user can either disable the validation through the xyplorer options, or they can ignore the warning and continue.

Regardless, I respect that there doesn't seem to be a 100% guaranteed solution to this problem, so I understand if you're unwilling to make the change. I'll just have to thin out my fingers.

admin
Site Admin
Posts: 66362
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: IP Address validation

Post by admin »

grsychckn wrote:Regardless, I respect that there doesn't seem to be a 100% guaranteed solution to this problem, so I understand if you're unwilling to make the change. I'll just have to thin out my fingers.
You could use scripting to build an input dialog with your own verfication algo...

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: IP Address validation

Post by TheQwerty »

admin wrote:You could use scripting to build an input dialog with your own verfication algo...
As a very simple example that does not have 100% coverage (and would be annoying to actually use often):

Code: Select all

"Goto Valid IP"
	$ip = Input('IP Validation Example', 'Enter the IP address you'd like to visit (without leading "\\"):', '127.0.0.1');
	$match = RegExReplace("$ip", '^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$', '');
	End(StrLen("$match") > 0, 'Format does not match an IP address.');
	$i = 0; while($i < 4) { $i++;
		$o = GetToken("$ip", $i, '.');
		End($o < 0 || $o > 255, 'Octet $i, "$o", is not valid.');
	}
	if (Confirm("Your input is a valid IP: $ip<br>Do you want to go to there?")) {
		Goto("\\$ip");
	}
Consider it your starting step for the IPv6 version. :P

Post Reply