ILIAS  release_4-4 Revision
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 32 of file IPv4.php.

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

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

◆ validate()

HTMLPurifier_AttrDef_URI_IPv4::validate (   $aIP,
  $config,
  $context 
)

Definition at line 15 of file IPv4.php.

References _loadRegex().

15  {
16 
17  if (!$this->ip4) $this->_loadRegex();
18 
19  if (preg_match('#^' . $this->ip4 . '$#s', $aIP))
20  {
21  return $aIP;
22  }
23 
24  return false;
25 
26  }
_loadRegex()
Lazy load function to prevent regex from being stuffed in cache.
Definition: IPv4.php:32
+ 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.

Definition at line 13 of file IPv4.php.


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