function drupal_valid_http_host

Same name and namespace in other branches
  1. 6.x drupal-6.x/includes/bootstrap.inc \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 drupal-7.x/modules/simpletest/tests/bootstrap.test
test IP Address and hostname
drupal_environment_initialize in drupal-7.x/includes/bootstrap.inc
Initializes the PHP environment.

Archivo

drupal-7.x/includes/bootstrap.inc, line 701
Functions that need to be loaded on every Drupal request.

Código

function drupal_valid_http_host($host) {
  return preg_match('/^\[?(?:[a-zA-Z0-9-:\]_]+\.?)+$/', $host);
}