diff options
author | ArthurHoaro <arthur@hoa.ro> | 2015-09-18 13:26:36 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2015-11-26 20:14:38 +0100 |
commit | 90e5bd65c9d4a5d3d5cedfeaa1314f2a15df5227 (patch) | |
tree | 7a085b9aecaa92aa5076df01df78c39edd2acff5 /tests/UtilsTest.php | |
parent | 986afb752bc57271e76935da9ed2df6ef8713cb7 (diff) | |
download | Shaarli-90e5bd65c9d4a5d3d5cedfeaa1314f2a15df5227.tar.gz Shaarli-90e5bd65c9d4a5d3d5cedfeaa1314f2a15df5227.tar.zst Shaarli-90e5bd65c9d4a5d3d5cedfeaa1314f2a15df5227.zip |
URL encode links when a redirector is set.
Fixes #328 - URL encode links when a redirector is set
* WARNING - template edit - new variable available : "real_url"
Contains the final real url (redirected or any other change on original URL)
* Don't redirect shaares link in RSS/Atom.
* Affects links shaared in description.
* Move text2clickable and keepMultipleSpaces to Utils.php + unit test
UPDATE:
* keepMultipleSpaces renamed to space2nbsp
* space2nbsp improved to handle single space at line beginning
* links in text description aren't 'nofollow' anymore
Diffstat (limited to 'tests/UtilsTest.php')
-rw-r--r-- | tests/UtilsTest.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/UtilsTest.php b/tests/UtilsTest.php index 4847ea94..02eecda2 100644 --- a/tests/UtilsTest.php +++ b/tests/UtilsTest.php | |||
@@ -187,4 +187,41 @@ class UtilsTest extends PHPUnit_Framework_TestCase | |||
187 | is_session_id_valid('c0ZqcWF3VFE2NmJBdm1HMVQ0ZHJ3UmZPbTFsNGhkNHI=') | 187 | is_session_id_valid('c0ZqcWF3VFE2NmJBdm1HMVQ0ZHJ3UmZPbTFsNGhkNHI=') |
188 | ); | 188 | ); |
189 | } | 189 | } |
190 | |||
191 | /** | ||
192 | * Test text2clickable without a redirector being set. | ||
193 | */ | ||
194 | public function testText2clickableWithoutRedirector() | ||
195 | { | ||
196 | $text = 'stuff http://hello.there/is=someone#here otherstuff'; | ||
197 | $expectedText = 'stuff <a href="http://hello.there/is=someone#here">http://hello.there/is=someone#here</a> otherstuff'; | ||
198 | $processedText = text2clickable($text, ''); | ||
199 | $this->assertEquals($expectedText, $processedText); | ||
200 | } | ||
201 | |||
202 | /** | ||
203 | * Test text2clickable a redirector set. | ||
204 | */ | ||
205 | public function testText2clickableWithRedirector() | ||
206 | { | ||
207 | $text = 'stuff http://hello.there/is=someone#here otherstuff'; | ||
208 | $redirector = 'http://redirector.to'; | ||
209 | $expectedText = 'stuff <a href="'. | ||
210 | $redirector . | ||
211 | urlencode('http://hello.there/is=someone#here') . | ||
212 | '">http://hello.there/is=someone#here</a> otherstuff'; | ||
213 | $processedText = text2clickable($text, $redirector); | ||
214 | $this->assertEquals($expectedText, $processedText); | ||
215 | } | ||
216 | |||
217 | /** | ||
218 | * Test testSpace2nbsp. | ||
219 | */ | ||
220 | public function testSpace2nbsp() | ||
221 | { | ||
222 | $text = ' Are you thrilled by flags ?'. PHP_EOL .' Really?'; | ||
223 | $expectedText = ' Are you thrilled by flags ?'. PHP_EOL .' Really?'; | ||
224 | $processedText = space2nbsp($text); | ||
225 | $this->assertEquals($expectedText, $processedText); | ||
226 | } | ||
190 | } | 227 | } |