ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
HTMLPurifier_AttrDef_HTML_Pixels Class Reference

Validates an integer representation of pixels according to the HTML spec. More...

+ Inheritance diagram for HTMLPurifier_AttrDef_HTML_Pixels:
+ Collaboration diagram for HTMLPurifier_AttrDef_HTML_Pixels:

Public Member Functions

 __construct ($max=null)
 
 validate ($string, $config, $context)
 
 make ($string)
 
- Public Member Functions inherited from HTMLPurifier_AttrDef
 validate ($string, $config, $context)
 Validates and cleans passed string according to a definition. More...
 
 parseCDATA ($string)
 Convenience method that parses a string as if it were CDATA. More...
 
 make ($string)
 Factory method for creating this class from a string. More...
 

Protected Attributes

 $max
 int More...
 

Additional Inherited Members

- Data Fields inherited from HTMLPurifier_AttrDef
 $minimized = false
 Tells us whether or not an HTML attribute is minimized. More...
 
 $required = false
 Tells us whether or not an HTML attribute is required. More...
 
- Protected Member Functions inherited from HTMLPurifier_AttrDef
 mungeRgb ($string)
 Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work properly. More...
 
 expandCSSEscape ($string)
 Parses a possibly escaped CSS string and returns the "pure" version of it. More...
 

Detailed Description

Validates an integer representation of pixels according to the HTML spec.

Definition at line 6 of file Pixels.php.

Constructor & Destructor Documentation

◆ __construct()

HTMLPurifier_AttrDef_HTML_Pixels::__construct (   $max = null)
Parameters
int$max

Definition at line 17 of file Pixels.php.

References $max.

18  {
19  $this->max = $max;
20  }

Member Function Documentation

◆ make()

HTMLPurifier_AttrDef_HTML_Pixels::make (   $string)
Parameters
string$string
Returns
HTMLPurifier_AttrDef

Definition at line 64 of file Pixels.php.

References $max.

65  {
66  if ($string === '') {
67  $max = null;
68  } else {
69  $max = (int)$string;
70  }
71  $class = get_class($this);
72  return new $class($max);
73  }

◆ validate()

HTMLPurifier_AttrDef_HTML_Pixels::validate (   $string,
  $config,
  $context 
)
Parameters
string$string
HTMLPurifier_Config$config
HTMLPurifier_Context$context
Returns
bool|string

Definition at line 28 of file Pixels.php.

References $max.

29  {
30  $string = trim($string);
31  if ($string === '0') {
32  return $string;
33  }
34  if ($string === '') {
35  return false;
36  }
37  $length = strlen($string);
38  if (substr($string, $length - 2) == 'px') {
39  $string = substr($string, 0, $length - 2);
40  }
41  if (!is_numeric($string)) {
42  return false;
43  }
44  $int = (int)$string;
45 
46  if ($int < 0) {
47  return '0';
48  }
49 
50  // upper-bound value, extremely high values can
51  // crash operating systems, see <http://ha.ckers.org/imagecrash.html>
52  // WARNING, above link WILL crash you if you're using Windows
53 
54  if ($this->max !== null && $int > $this->max) {
55  return (string)$this->max;
56  }
57  return (string)$int;
58  }

Field Documentation

◆ $max

HTMLPurifier_AttrDef_HTML_Pixels::$max
protected

int

Definition at line 12 of file Pixels.php.

Referenced by __construct(), make(), and validate().


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