ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
HTMLPurifier_AttrTransform_TargetNoreferrer Class Reference

Adds rel="noreferrer" to any links which target a different window than the current one. More...

+ Inheritance diagram for HTMLPurifier_AttrTransform_TargetNoreferrer:
+ Collaboration diagram for HTMLPurifier_AttrTransform_TargetNoreferrer:

Public Member Functions

 transform ($attr, $config, $context)
 
- Public Member Functions inherited from HTMLPurifier_AttrTransform
 transform ($attr, $config, $context)
 Abstract: makes changes to the attributes dependent on multiple values. More...
 
 prependCSS (&$attr, $css)
 Prepends CSS properties to the style attribute, creating the attribute if it doesn't exist. More...
 
 confiscateAttr (&$attr, $key)
 Retrieves and removes an attribute. More...
 

Detailed Description

Adds rel="noreferrer" to any links which target a different window than the current one.

This is used to prevent malicious websites from silently replacing the original window, which could be used to do phishing. This transform is controlled by HTML.TargetNoreferrer.

Definition at line 12 of file TargetNoreferrer.php.

Member Function Documentation

◆ transform()

HTMLPurifier_AttrTransform_TargetNoreferrer::transform (   $attr,
  $config,
  $context 
)
Parameters
array$attr
HTMLPurifier_Config$config
HTMLPurifier_Context$context
Returns
array

Definition at line 20 of file TargetNoreferrer.php.

References array.

21  {
22  if (isset($attr['rel'])) {
23  $rels = explode(' ', $attr['rel']);
24  } else {
25  $rels = array();
26  }
27  if (isset($attr['target']) && !in_array('noreferrer', $rels)) {
28  $rels[] = 'noreferrer';
29  }
30  if (!empty($rels) || isset($attr['rel'])) {
31  $attr['rel'] = implode(' ', $rels);
32  }
33 
34  return $attr;
35  }
Create styles array
The data for the language used.

The documentation for this class was generated from the following file: