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

Validates an IPv4 address. More...

+ Inheritance diagram for HTMLPurifier_AttrDef_URI_IPv4:
+ Collaboration diagram for HTMLPurifier_AttrDef_URI_IPv4:

Public Member Functions

 validate ($aIP, $config, $context)
 
- 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 Member Functions

 _loadRegex ()
 Lazy load function to prevent regex from being stuffed in cache. 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

 $ip4
 IPv4 regex, protected so that IPv6 can reuse it. 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...
 

Detailed Description

Validates an IPv4 address.

Author
Feyd @ forums.devnetwork.net (public domain)

Definition at line 7 of file IPv4.php.

Member Function Documentation

◆ _loadRegex()

HTMLPurifier_AttrDef_URI_IPv4::_loadRegex ( )
protected

Lazy load function to prevent regex from being stuffed in cache.

Definition at line 38 of file IPv4.php.

Referenced by HTMLPurifier_AttrDef_URI_IPv6\validate(), and validate().

39  {
40  $oct = '(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])'; // 0-255
41  $this->ip4 = "(?:{$oct}\\.{$oct}\\.{$oct}\\.{$oct})";
42  }
+ Here is the caller graph for this function:

◆ validate()

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

Definition at line 22 of file IPv4.php.

References _loadRegex().

23  {
24  if (!$this->ip4) {
25  $this->_loadRegex();
26  }
27 
28  if (preg_match('#^' . $this->ip4 . '$#s', $aIP)) {
29  return $aIP;
30  }
31  return false;
32  }
_loadRegex()
Lazy load function to prevent regex from being stuffed in cache.
Definition: IPv4.php:38
+ Here is the call graph for this function:

Field Documentation

◆ $ip4

HTMLPurifier_AttrDef_URI_IPv4::$ip4
protected

IPv4 regex, protected so that IPv6 can reuse it.

string

Definition at line 14 of file IPv4.php.


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