‪TYPO3CMS  ‪main
UrlLinkHandler.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
22 {
26  public function ‪asString(array $parameters): string
27  {
28  return $this->‪addHttpSchemeAsFallback($parameters['url']);
29  }
30 
36  public function ‪resolveHandlerData(array $data): array
37  {
38  return ['url' => $this->‪addHttpSchemeAsFallback($data['url'])];
39  }
40 
46  protected function ‪addHttpSchemeAsFallback(string ‪$url): string
47  {
48  if (!empty(‪$url)) {
49  // We expect this an absolute path, and leave as is. We also leave double slashes ('//') as is.
50  if (str_starts_with(‪$url, '/')) {
51  return ‪$url;
52  }
53  $scheme = parse_url(‪$url, PHP_URL_SCHEME);
54  if (empty($scheme)) {
56  } elseif (in_array(strtolower($scheme), ['javascript', 'data'], true)) {
57  // deny using insecure scheme's like `javascript:` or `data:` as URL scheme
58  ‪$url = '';
59  }
60  }
61  return ‪$url;
62  }
63 
69  public static function ‪getDefaultScheme(): string
70  {
71  return (‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['defaultScheme'] ?? '')
73  }
74 }
‪TYPO3\CMS\Webhooks\Message\$url
‪identifier readonly UriInterface $url
Definition: LoginErrorOccurredMessage.php:36
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25