3 // must be called POST validation
6 * Adds target="blank" to all outbound links. This transform is
7 * only attached if Attr.TargetBlank is TRUE. This works regardless
8 * of whether or not Attr.AllowedFrameTargets
10 class HTMLPurifier_AttrTransform_TargetBlank
extends HTMLPurifier_AttrTransform
14 public function __construct() {
15 $this->parser
= new HTMLPurifier_URIParser();
18 public function transform($attr, $config, $context) {
20 if (!isset($attr['href'])) {
24 // XXX Kind of inefficient
25 $url = $this->parser
->parse($attr['href']);
26 $scheme = $url->getSchemeObj($config, $context);
28 if ($scheme->browsable
&& !$url->isBenign($config, $context)) {
29 $attr['target'] = 'blank';