‪TYPO3CMS  11.5
UrlLinkHandlerTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
24 class ‪UrlLinkHandlerTest extends UnitTestCase
25 {
32  {
33  return [
34  'URL without a scheme' => [
35  [
36  'url' => 'www.have.you/ever?did=this',
37  ],
38  [
39  'url' => 'http://www.have.you/ever?did=this',
40  ],
41  'http://www.have.you/ever?did=this',
42  ],
43  'http URL' => [
44  [
45  'url' => 'http://www.have.you/ever?did=this',
46  ],
47  [
48  'url' => 'http://www.have.you/ever?did=this',
49  ],
50  'http://www.have.you/ever?did=this',
51  ],
52  'https URL' => [
53  [
54  'url' => 'https://www.have.you/ever?did=this',
55  ],
56  [
57  'url' => 'https://www.have.you/ever?did=this',
58  ],
59  'https://www.have.you/ever?did=this',
60  ],
61  'https URL with port' => [
62  [
63  'url' => 'https://www.have.you:8088/ever?did=this',
64  ],
65  [
66  'url' => 'https://www.have.you:8088/ever?did=this',
67  ],
68  'https://www.have.you:8088/ever?did=this',
69  ],
70  'ftp URL' => [
71  [
72  'url' => 'ftp://www.have.you/ever?did=this',
73  ],
74  [
75  'url' => 'ftp://www.have.you/ever?did=this',
76  ],
77  'ftp://www.have.you/ever?did=this',
78  ],
79  'afp URL' => [
80  [
81  'url' => 'afp://www.have.you/ever?did=this',
82  ],
83  [
84  'url' => 'afp://www.have.you/ever?did=this',
85  ],
86  'afp://www.have.you/ever?did=this',
87  ],
88  'sftp URL' => [
89  [
90  'url' => 'sftp://nice:andsecret@www.have.you:23/ever?did=this',
91  ],
92  [
93  'url' => 'sftp://nice:andsecret@www.have.you:23/ever?did=this',
94  ],
95  'sftp://nice:andsecret@www.have.you:23/ever?did=this',
96  ],
97  'tel URL' => [
98  ['url' => 'tel:+1-2345-6789'],
99  ['url' => 'tel:+1-2345-6789'],
100  'tel:+1-2345-6789',
101  ],
102  'javascript URL (denied)' => [
103  ['url' => 'javascript:alert(\'XSS\')'],
104  ['url' => ''],
105  '',
106  ],
107  'data URL (denied)' => [
108  ['url' => 'data:text/html;base64,SGVsbG8sIFdvcmxkIQ%3D%3D'],
109  ['url' => ''],
110  '',
111  ],
112  ];
113  }
114 
120  public function ‪resolveReturnsSplitParameters(array $input, array $expected, string $finalString): void
121  {
122  $subject = new ‪UrlLinkHandler();
123  self::assertEquals($expected, $subject->resolveHandlerData($input));
124  }
125 
131  public function ‪splitParametersToUnifiedIdentifier(array $input, array $parameters, string $expected): void
132  {
133  $subject = new ‪UrlLinkHandler();
134  self::assertEquals($expected, $subject->asString($parameters));
135  }
136 
141  {
142  unset(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['defaultScheme']);
143 
145 
146  self::assertSame(‪LinkHandlingInterface::DEFAULT_SCHEME, $result);
147  }
148 
153  {
154  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['defaultScheme'] = '';
155 
157 
158  self::assertSame(‪LinkHandlingInterface::DEFAULT_SCHEME, $result);
159  }
160 
165  {
166  $scheme = 'https';
167  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['defaultScheme'] = $scheme;
168 
170 
171  self::assertSame($scheme, $result);
172  }
173 }
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25