diff options
| author | Cash Costello <cash.costello@gmail.com> | 2013-04-20 09:10:50 -0700 | 
|---|---|---|
| committer | Cash Costello <cash.costello@gmail.com> | 2013-04-20 09:10:50 -0700 | 
| commit | 392a3c7c94bfbe4d462d0cac1e89d6d87c4c06e4 (patch) | |
| tree | bfd9741ec9c161dd987d3df91b055d3316a313bf /engine/tests/regression/trac_bugs.php | |
| parent | 39886afeec37309963be57551699c7bfc3f6c37b (diff) | |
| parent | 164ff10b46d5917c7ab6ad068abf10e492464691 (diff) | |
| download | elgg-392a3c7c94bfbe4d462d0cac1e89d6d87c4c06e4.tar.gz elgg-392a3c7c94bfbe4d462d0cac1e89d6d87c4c06e4.tar.bz2  | |
Merge pull request #5385 from cash/parse_urls
Fixes #5369 allows ! in urls and adds unit tests
Diffstat (limited to 'engine/tests/regression/trac_bugs.php')
| -rw-r--r-- | engine/tests/regression/trac_bugs.php | 52 | 
1 files changed, 52 insertions, 0 deletions
diff --git a/engine/tests/regression/trac_bugs.php b/engine/tests/regression/trac_bugs.php index 58444dd39..4de9c306b 100644 --- a/engine/tests/regression/trac_bugs.php +++ b/engine/tests/regression/trac_bugs.php @@ -236,4 +236,56 @@ class ElggCoreRegressionBugsTest extends ElggCoreUnitTest {  			$this->assertIdentical($expected, $friendly_title);  		}  	} + +	/** +	 * Test #5369 -- parse_urls() +	 * https://github.com/Elgg/Elgg/issues/5369 +	 */ +	public function test_parse_urls() { + +		$cases = array( +			'no.link.here' => +				'no.link.here', +			'simple link http://example.org test' => +				'simple link <a href="http://example.org" rel="nofollow">http:/<wbr />/<wbr />example.org</a> test', +			'non-ascii http://ñew.org/ test' => +				'non-ascii <a href="http://ñew.org/" rel="nofollow">http:/<wbr />/<wbr />ñew.org/<wbr /></a> test', + +			// section 2.1 +			'percent encoded http://example.org/a%20b test' => +				'percent encoded <a href="http://example.org/a%20b" rel="nofollow">http:/<wbr />/<wbr />example.org/<wbr />a%20b</a> test', +			// section 2.2: skipping single quote and parenthese +			'reserved characters http://example.org/:/?#[]@!$&*+,;= test' => +				'reserved characters <a href="http://example.org/:/?#[]@!$&*+,;=" rel="nofollow">http:/<wbr />/<wbr />example.org/<wbr />:/<wbr />?#[]@!$&*+,;=</a> test', +			// section 2.3 +			'unreserved characters http://example.org/a1-._~ test' => +				'unreserved characters <a href="http://example.org/a1-._~" rel="nofollow">http:/<wbr />/<wbr />example.org/<wbr />a1-._~</a> test', + +			'parameters http://example.org/?val[]=1&val[]=2 test' => +				'parameters <a href="http://example.org/?val[]=1&val[]=2" rel="nofollow">http:/<wbr />/<wbr />example.org/<wbr />?val[]=1&val[]=2</a> test', +			'port http://example.org:80/ test' => +				'port <a href="http://example.org:80/" rel="nofollow">http:/<wbr />/<wbr />example.org:80/<wbr /></a> test', + +			'parentheses (http://www.google.com) test' => +				'parentheses (<a href="http://www.google.com" rel="nofollow">http:/<wbr />/<wbr />www.google.com</a>) test', +			'comma http://elgg.org, test' => +				'comma <a href="http://elgg.org" rel="nofollow">http:/<wbr />/<wbr />elgg.org</a>, test', +			'period http://elgg.org. test' => +				'period <a href="http://elgg.org" rel="nofollow">http:/<wbr />/<wbr />elgg.org</a>. test', +			'exclamation http://elgg.org! test' => +				'exclamation <a href="http://elgg.org" rel="nofollow">http:/<wbr />/<wbr />elgg.org</a>! test', + +			'already anchor <a href="http://twitter.com/">twitter</a> test' => +				'already anchor <a href="http://twitter.com/">twitter</a> test', + +			'ssl https://example.org/ test' => +				'ssl <a href="https://example.org/" rel="nofollow">https:/<wbr />/<wbr />example.org/<wbr /></a> test', +			'ftp ftp://example.org/ test' => +				'ftp <a href="ftp://example.org/" rel="nofollow">ftp:/<wbr />/<wbr />example.org/<wbr /></a> test', + +		); +		foreach ($cases as $input => $output) { +			$this->assertEqual($output, parse_urls($input)); +		} +	}  }  | 
