Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Static Public Member Functions
Zend_Http_Header_HeaderValue Class Reference

Static Public Member Functions

static filter ($value)
 
static isValid ($value)
 
static assertValid ($value)
 

Detailed Description

Definition at line 31 of file HeaderValue.php.

Member Function Documentation

◆ assertValid()

static assertValid (   $value)
static

Assert a header value is valid.

Parameters
string$value
Exceptions
Exception

Definition at line 120 of file HeaderValue.php.

121  {
122  if (! self::isValid($value)) {
123  #require_once 'Zend/Http/Header/Exception/InvalidArgumentException.php';
124  throw new Zend_Http_Header_Exception_InvalidArgumentException('Invalid header value');
125  }
126  }
$value
Definition: gender.phtml:16

◆ filter()

static filter (   $value)
static

Filter a header value

Ensures CRLF header injection vectors are filtered.

Per RFC 7230, only VISIBLE ASCII characters, spaces, and horizontal tabs are allowed in values; only one whitespace character is allowed between visible characters.

See also
http://en.wikipedia.org/wiki/HTTP_response_splitting
Parameters
string$value
Returns
string

Definition at line 53 of file HeaderValue.php.

54  {
55  $value = (string) $value;
56  $length = strlen($value);
57  $string = '';
58  for ($i = 0; $i < $length; $i += 1) {
59  $ascii = ord($value[$i]);
60 
61  // Non-visible, non-whitespace characters
62  // 9 === horizontal tab
63  // 32-126, 128-254 === visible
64  // 127 === DEL
65  // 255 === null byte
66  if (($ascii < 32 && $ascii !== 9)
67  || $ascii === 127
68  || $ascii > 254
69  ) {
70  continue;
71  }
72 
73  $string .= $value[$i];
74  }
75 
76  return $string;
77  }
$value
Definition: gender.phtml:16
$i
Definition: gallery.phtml:31

◆ isValid()

static isValid (   $value)
static

Validate a header value.

Per RFC 7230, only VISIBLE ASCII characters, spaces, and horizontal tabs are allowed in values; only one whitespace character is allowed between visible characters.

See also
http://en.wikipedia.org/wiki/HTTP_response_splitting
Parameters
string$value
Returns
bool

Definition at line 90 of file HeaderValue.php.

91  {
92  $value = (string) $value;
93  $length = strlen($value);
94  for ($i = 0; $i < $length; $i += 1) {
95  $ascii = ord($value[$i]);
96 
97  // Non-visible, non-whitespace characters
98  // 9 === horizontal tab
99  // 32-126, 128-254 === visible
100  // 127 === DEL
101  // 255 === null byte
102  if (($ascii < 32 && $ascii !== 9)
103  || $ascii === 127
104  || $ascii > 254
105  ) {
106  return false;
107  }
108  }
109 
110  return true;
111  }
$value
Definition: gender.phtml:16
$i
Definition: gallery.phtml:31

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