function drupal_valid_http_host
Validates that a hostname (for example $_SERVER['HTTP_HOST']) is safe.
Return value
TRUE if only containing valid characters, or FALSE otherwise.
2 calls to drupal_valid_http_host()
- BootstrapIPAddressTestCase::testIPAddressHost in modules/
simpletest/ tests/ bootstrap.test - test IP Address and hostname
- drupal_environment_initialize in includes/
bootstrap.inc - Initializes the PHP environment.
File
-
includes/
bootstrap.inc, line 735
Code
function drupal_valid_http_host($host) {
// Limit the length of the host name to 1000 bytes to prevent DoS attacks with
// long host names.
return strlen($host) <= 1000 && substr_count($host, '.') <= 100 && substr_count($host, ':') <= 100 && preg_match('/^\\[?(?:[a-zA-Z0-9-:\\]_]+\\.?)+$/', $host);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.