mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Revert "Update RFC1123 Hostname Check" (#7577)
* Revert "Revert "feature: Allow snmpget in os discovery yaml (#7558)" (#7576)" This reverts commit 426916dbe47d31a38e042aad98915eb618c04760. * Revert "fix: lldp find_port_id finds not the most correct port (#7564)" This reverts commit 7e05fff615bb765262f2abde36219ea691ee7f99. * Revert "fix: Update RFC1123 Hostname Check (#7572)" This reverts commit ebcfa45a933991f35ece3a643a552e161a1825bf.
This commit is contained in:
@ -629,9 +629,9 @@ function is_valid_hostname($hostname)
|
||||
// maximum length is 253 characters, maximum segment size is 63
|
||||
|
||||
return (
|
||||
preg_match("/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\.?$/", $hostname) //valid chars check
|
||||
preg_match("/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*\.?$/i", $hostname) //valid chars check
|
||||
&& preg_match("/^.{1,253}$/", $hostname) //overall length check
|
||||
&& preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*\.?$/", $hostname) //segment length check
|
||||
&& preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*\.?$/", $hostname)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -129,16 +129,11 @@ class CommonFunctionsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue(is_valid_hostname('google.com'), 'google.com');
|
||||
$this->assertTrue(is_valid_hostname('news.google.co.uk'), 'news.google.co.uk');
|
||||
$this->assertTrue(is_valid_hostname('xn--fsqu00a.xn--0zwm56d'), 'xn--fsqu00a.xn--0zwm56d');
|
||||
$this->assertTrue(is_valid_hostname('www.averylargedomainthatdoesnotreallyexist.com'), 'www.averylargedomainthatdoesnotreallyexist.com');
|
||||
$this->assertTrue(is_valid_hostname('cont-ains.h-yph-en-s.com'), 'cont-ains.h-yph-en-s.com');
|
||||
$this->assertTrue(is_valid_hostname('cisco-3750x'), 'cisco-3750x');
|
||||
$this->assertFalse(is_valid_hostname('cisco_3750x'), 'cisco_3750x');
|
||||
$this->assertFalse(is_valid_hostname('goo gle.com'), 'goo gle.com');
|
||||
$this->assertFalse(is_valid_hostname('google..com'), 'google..com');
|
||||
$this->assertFalse(is_valid_hostname('google.com '), 'google.com ');
|
||||
$this->assertFalse(is_valid_hostname('google-.com'), 'google-.com');
|
||||
$this->assertFalse(is_valid_hostname('.google.com'), '.google.com');
|
||||
$this->assertFalse(is_valid_hostname('..google.com'), '..google.com');
|
||||
$this->assertFalse(is_valid_hostname('<script'), '<script');
|
||||
$this->assertFalse(is_valid_hostname('alert('), 'alert(');
|
||||
$this->assertFalse(is_valid_hostname('.'), '.');
|
||||
|
Reference in New Issue
Block a user