diff options
author | Evan Prodromou <evan@status.net> | 2010-10-18 11:05:03 -0400 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2010-10-18 11:05:03 -0400 |
commit | 90a53f6cde1e3344483953b8f0ce894227e919d6 (patch) | |
tree | 9bcebf34355f4eb2dd2cfc77f86744ceb5affa26 | |
parent | 505ac6eba0e671e8823b5102de3caa0e0040c2cf (diff) |
add rel='nofollow' to external links
-rw-r--r-- | lib/default.php | 3 | ||||
-rw-r--r-- | lib/util.php | 14 |
2 files changed, 14 insertions, 3 deletions
diff --git a/lib/default.php b/lib/default.php index fb032930b..375088130 100644 --- a/lib/default.php +++ b/lib/default.php @@ -317,7 +317,8 @@ $default = 'nofollow' => array('subscribers' => true, 'members' => true, - 'peopletag' => true), + 'peopletag' => true, + 'external' => 'always'), // Options: 'sometimes', 'never', default = 'always' 'http' => // HTTP client settings when contacting other sites array('ssl_cafile' => false, // To enable SSL cert validation, point to a CA bundle (eg '/usr/lib/ssl/certs/ca-certificates.crt') 'curl' => false, // Use CURL backend for HTTP fetches if available. (If not, PHP's socket streams will be used.) diff --git a/lib/util.php b/lib/util.php index c05fcf15a..5a94182bd 100644 --- a/lib/util.php +++ b/lib/util.php @@ -145,7 +145,6 @@ function common_switch_locale($language=null) textdomain("statusnet"); } - function common_timezone() { if (common_logged_in()) { @@ -860,7 +859,8 @@ function common_linkify($url) { $longurl = $url; } } - $attrs = array('href' => $canon, 'title' => $longurl, 'rel' => 'external'); + + $attrs = array('href' => $canon, 'title' => $longurl); $is_attachment = false; $attachment_id = null; @@ -896,6 +896,16 @@ function common_linkify($url) { $attrs['id'] = "attachment-{$attachment_id}"; } + // Whether to nofollow + + $nf = common_config('nofollow', 'external'); + + if ($nf == 'never') { + $attrs['rel'] = 'external'; + } else { + $attrs['rel'] = 'nofollow external'; + } + return XMLStringer::estring('a', $attrs, $url); } |