3 // must be called POST validation
6 * Adds rel="nofollow" to all outbound links. This transform is
7 * only attached if Attr.Nofollow is TRUE.
9 class HTMLPurifier_AttrTransform_Nofollow
extends HTMLPurifier_AttrTransform
13 public function __construct() {
14 $this->parser
= new HTMLPurifier_URIParser();
17 public function transform($attr, $config, $context) {
19 if (!isset($attr['href'])) {
23 // XXX Kind of inefficient
24 $url = $this->parser
->parse($attr['href']);
25 $scheme = $url->getSchemeObj($config, $context);
27 if ($scheme->browsable
&& !$url->isLocal($config, $context)) {
28 if (isset($attr['rel'])) {
29 $rels = explode(' ', $attr['rel']);
30 if (!in_array('nofollow', $rels)) {
33 $attr['rel'] = implode(' ', $rels);
35 $attr['rel'] = 'nofollow';