Page 2 of 2
Re: IP Address validation
Posted: 03 Jan 2011 23:52
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.
Re: IP Address validation
Posted: 04 Jan 2011 08:18
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...
Re: IP Address validation
Posted: 04 Jan 2011 12:35
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.
