TYPO3 CMS  TYPO3_8-7
UrlLinkHandlerTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
19 class UrlLinkHandlerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
20 {
21 
28  {
29  return [
30  'URL without a scheme' => [
31  [
32  'url' => 'www.have.you/ever?did=this'
33  ],
34  [
35  'url' => 'http://www.have.you/ever?did=this'
36  ],
37  'http://www.have.you/ever?did=this'
38  ],
39  'http URL' => [
40  [
41  'url' => 'http://www.have.you/ever?did=this'
42  ],
43  [
44  'url' => 'http://www.have.you/ever?did=this'
45  ],
46  'http://www.have.you/ever?did=this'
47  ],
48  'https URL' => [
49  [
50  'url' => 'https://www.have.you/ever?did=this'
51  ],
52  [
53  'url' => 'https://www.have.you/ever?did=this'
54  ],
55  'https://www.have.you/ever?did=this'
56  ],
57  'https URL with port' => [
58  [
59  'url' => 'https://www.have.you:8088/ever?did=this'
60  ],
61  [
62  'url' => 'https://www.have.you:8088/ever?did=this'
63  ],
64  'https://www.have.you:8088/ever?did=this'
65  ],
66  'ftp URL' => [
67  [
68  'url' => 'ftp://www.have.you/ever?did=this'
69  ],
70  [
71  'url' => 'ftp://www.have.you/ever?did=this'
72  ],
73  'ftp://www.have.you/ever?did=this'
74  ],
75  'afp URL' => [
76  [
77  'url' => 'afp://www.have.you/ever?did=this'
78  ],
79  [
80  'url' => 'afp://www.have.you/ever?did=this'
81  ],
82  'afp://www.have.you/ever?did=this'
83  ],
84  'sftp URL' => [
85  [
86  'url' => 'sftp://nice:andsecret@www.have.you:23/ever?did=this'
87  ],
88  [
89  'url' => 'sftp://nice:andsecret@www.have.you:23/ever?did=this'
90  ],
91  'sftp://nice:andsecret@www.have.you:23/ever?did=this'
92  ],
93  'tel URL' => [
94  ['url' => 'tel:+1-2345-6789'],
95  ['url' => 'tel:+1-2345-6789'],
96  'tel:+1-2345-6789'
97  ],
98  'javascript URL (denied)' => [
99  ['url' => 'javascript:alert(\'XSS\')'],
100  ['url' => ''],
101  ''
102  ],
103  'data URL (denied)' => [
104  ['url' => 'data:text/html;base64,SGVsbG8sIFdvcmxkIQ%3D%3D'],
105  ['url' => ''],
106  ''
107  ],
108  ];
109  }
110 
120  public function resolveReturnsSplitParameters($input, $expected, $finalString)
121  {
122  $subject = new UrlLinkHandler();
123  $this->assertEquals($expected, $subject->resolveHandlerData($input));
124  }
125 
135  public function splitParametersToUnifiedIdentifier($input, $parameters, $expected)
136  {
137  $subject = new UrlLinkHandler();
138  $this->assertEquals($expected, $subject->asString($parameters));
139  }
140 }