Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DrupalKernel.php

function DrupalKernel::validateHostname

Validates the hostname supplied from the HTTP request.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request object

Return value

bool TRUE if the hostname is valid, or FALSE otherwise.

1 call to DrupalKernel::validateHostname()
DrupalKernel::findSitePath in core/lib/Drupal/Core/DrupalKernel.php
Returns the appropriate site directory for a request.

File

core/lib/Drupal/Core/DrupalKernel.php, line 1579

Class

DrupalKernel
The DrupalKernel class is the core of Drupal itself.

Namespace

Drupal\Core

Code

public static function validateHostname(Request $request) {
    // $request->getHost() can throw an UnexpectedValueException if it
    // detects a bad hostname, but it does not validate the length.
    try {
        $http_host = $request->getHost();
    } catch (\UnexpectedValueException) {
        return FALSE;
    }
    if (static::validateHostnameLength($http_host) === FALSE) {
        return FALSE;
    }
    return TRUE;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal