ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
HTMLPurifier_AttrDef_HTML_MultiLength Class Reference

Validates a MultiLength as defined by the HTML spec. More...

+ Inheritance diagram for HTMLPurifier_AttrDef_HTML_MultiLength:
+ Collaboration diagram for HTMLPurifier_AttrDef_HTML_MultiLength:

Public Member Functions

 validate ($string, $config, $context)
 
- Public Member Functions inherited from HTMLPurifier_AttrDef_HTML_Length
 validate ($string, $config, $context)
 
- Public Member Functions inherited from HTMLPurifier_AttrDef_HTML_Pixels
 __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...
 

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...
 
- Protected Attributes inherited from HTMLPurifier_AttrDef_HTML_Pixels
 $max
 int More...
 

Detailed Description

Validates a MultiLength as defined by the HTML spec.

A multilength is either a integer (pixel count), a percentage, or a relative number.

Definition at line 9 of file MultiLength.php.

Member Function Documentation

◆ validate()

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

Definition at line 18 of file MultiLength.php.

References $config.

19  {
20  $string = trim($string);
21  if ($string === '') {
22  return false;
23  }
24 
25  $parent_result = parent::validate($string, $config, $context);
26  if ($parent_result !== false) {
27  return $parent_result;
28  }
29 
30  $length = strlen($string);
31  $last_char = $string[$length - 1];
32 
33  if ($last_char !== '*') {
34  return false;
35  }
36 
37  $int = substr($string, 0, $length - 1);
38 
39  if ($int == '') {
40  return '*';
41  }
42  if (!is_numeric($int)) {
43  return false;
44  }
45 
46  $int = (int)$int;
47  if ($int < 0) {
48  return false;
49  }
50  if ($int == 0) {
51  return '0';
52  }
53  if ($int == 1) {
54  return '*';
55  }
56  return ((string)$int) . '*';
57  }

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