| Versionen | |
|---|---|
| drupal6 – drupal7 | drupal_valid_http_host($host) |
Validate that a hostname (for example $_SERVER['HTTP_HOST']) is safe.
As $_SERVER['HTTP_HOST'] is user input, ensure it only contains characters allowed in hostnames. See RFC 952 (and RFC 2181). $_SERVER['HTTP_HOST'] is lowercased.
TRUE if only containing valid characters, or FALSE otherwise.
includes/
<?php
function drupal_valid_http_host($host) {
return preg_match('/^\[?(?:[a-z0-9-:\]_]+\.?)+$/', $host);
}
?>
Kommentare
Kommentar hinzufügen