You are here

public function IFrameUrlHelper::isSecure in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/media/src/IFrameUrlHelper.php \Drupal\media\IFrameUrlHelper::isSecure()

Checks if an oEmbed URL can be securely displayed in an frame.

Parameters

string $url: The URL to check.

Return value

bool TRUE if the URL is considered secure, otherwise FALSE.

File

core/modules/media/src/IFrameUrlHelper.php, line 72

Class

IFrameUrlHelper
Providers helper functions for displaying oEmbed resources in an iFrame.

Namespace

Drupal\media

Code

public function isSecure($url) {
  if (!$url) {
    return FALSE;
  }
  $url_host = parse_url($url, PHP_URL_HOST);
  $system_host = parse_url($this->requestContext
    ->getCompleteBaseUrl(), PHP_URL_HOST);

  // The URL is secure if its domain is not the same as the domain of the base
  // URL of the current request.
  return $url_host && $system_host && $url_host !== $system_host;
}