]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #5244 adds nofollow to anchor tags created by parse_urls()
authorcash <cash.costello@gmail.com>
Sat, 20 Apr 2013 16:08:27 +0000 (12:08 -0400)
committercash <cash.costello@gmail.com>
Sat, 20 Apr 2013 16:08:27 +0000 (12:08 -0400)
engine/lib/output.php
engine/tests/regression/trac_bugs.php

index fe5bbcaaf7f2ca0b2f3e946553cc504de88e8d09..6905b9b7183162995f988bf5ccd94a07c260e5cb 100644 (file)
@@ -39,7 +39,7 @@ function parse_urls($text) {
                                $url = rtrim($url, ".!,");
                        }
                        $urltext = str_replace("/", "/<wbr />", $url);
-                       return "<a href=\"$url\">$urltext</a>$punc";
+                       return "<a href=\"$url\" rel=\"nofollow\">$urltext</a>$punc";
                '
        ), $text);
 
index 83b78bc6b02a86ea25efc8e370ec34c1ab98598c..4de9c306bf90d43e5af8cf6375bf8424414acff0 100644 (file)
@@ -247,41 +247,41 @@ class ElggCoreRegressionBugsTest extends ElggCoreUnitTest {
                        'no.link.here' =>
                                'no.link.here',
                        'simple link http://example.org test' =>
-                               'simple link <a href="http://example.org">http:/<wbr />/<wbr />example.org</a> 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/">http:/<wbr />/<wbr />ñew.org/<wbr /></a> 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">http:/<wbr />/<wbr />example.org/<wbr />a%20b</a> 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/:/?#[]@!$&*+,;=">http:/<wbr />/<wbr />example.org/<wbr />:/<wbr />?#[]@!$&*+,;=</a> 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-._~">http:/<wbr />/<wbr />example.org/<wbr />a1-._~</a> 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">http:/<wbr />/<wbr />example.org/<wbr />?val[]=1&val[]=2</a> 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/">http:/<wbr />/<wbr />example.org:80/<wbr /></a> 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">http:/<wbr />/<wbr />www.google.com</a>) 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">http:/<wbr />/<wbr />elgg.org</a>, 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">http:/<wbr />/<wbr />elgg.org</a>. 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">http:/<wbr />/<wbr />elgg.org</a>! 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/">https:/<wbr />/<wbr />example.org/<wbr /></a> 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/">ftp:/<wbr />/<wbr />example.org/<wbr /></a> test',
+                               'ftp <a href="ftp://example.org/" rel="nofollow">ftp:/<wbr />/<wbr />example.org/<wbr /></a> test',
 
                );
                foreach ($cases as $input => $output) {