‪TYPO3CMS  10.4
UrlLinkHandlerTest.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 
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 
21 class ‪UrlLinkHandlerTest extends UnitTestCase
22 {
23 
30  {
31  return [
32  'URL without a scheme' => [
33  [
34  'url' => 'www.have.you/ever?did=this'
35  ],
36  [
37  'url' => 'http://www.have.you/ever?did=this'
38  ],
39  'http://www.have.you/ever?did=this'
40  ],
41  'http URL' => [
42  [
43  'url' => 'http://www.have.you/ever?did=this'
44  ],
45  [
46  'url' => 'http://www.have.you/ever?did=this'
47  ],
48  'http://www.have.you/ever?did=this'
49  ],
50  'https URL' => [
51  [
52  'url' => 'https://www.have.you/ever?did=this'
53  ],
54  [
55  'url' => 'https://www.have.you/ever?did=this'
56  ],
57  'https://www.have.you/ever?did=this'
58  ],
59  'https URL with port' => [
60  [
61  'url' => 'https://www.have.you:8088/ever?did=this'
62  ],
63  [
64  'url' => 'https://www.have.you:8088/ever?did=this'
65  ],
66  'https://www.have.you:8088/ever?did=this'
67  ],
68  'ftp URL' => [
69  [
70  'url' => 'ftp://www.have.you/ever?did=this'
71  ],
72  [
73  'url' => 'ftp://www.have.you/ever?did=this'
74  ],
75  'ftp://www.have.you/ever?did=this'
76  ],
77  'afp URL' => [
78  [
79  'url' => 'afp://www.have.you/ever?did=this'
80  ],
81  [
82  'url' => 'afp://www.have.you/ever?did=this'
83  ],
84  'afp://www.have.you/ever?did=this'
85  ],
86  'sftp URL' => [
87  [
88  'url' => 'sftp://nice:andsecret@www.have.you:23/ever?did=this'
89  ],
90  [
91  'url' => 'sftp://nice:andsecret@www.have.you:23/ever?did=this'
92  ],
93  'sftp://nice:andsecret@www.have.you:23/ever?did=this'
94  ],
95  'tel URL' => [
96  ['url' => 'tel:+1-2345-6789'],
97  ['url' => 'tel:+1-2345-6789'],
98  'tel:+1-2345-6789'
99  ],
100  'javascript URL (denied)' => [
101  ['url' => 'javascript:alert(\'XSS\')'],
102  ['url' => ''],
103  ''
104  ],
105  'data URL (denied)' => [
106  ['url' => 'data:text/html;base64,SGVsbG8sIFdvcmxkIQ%3D%3D'],
107  ['url' => ''],
108  ''
109  ],
110  ];
111  }
112 
122  public function ‪resolveReturnsSplitParameters($input, $expected, $finalString)
123  {
124  $subject = new ‪UrlLinkHandler();
125  self::assertEquals($expected, $subject->resolveHandlerData($input));
126  }
127 
137  public function ‪splitParametersToUnifiedIdentifier($input, $parameters, $expected)
138  {
139  $subject = new ‪UrlLinkHandler();
140  self::assertEquals($expected, $subject->asString($parameters));
141  }
142 }