comparison vendor/symfony/browser-kit/Cookie.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 5fb285c0d0e3
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
20 { 20 {
21 /** 21 /**
22 * Handles dates as defined by RFC 2616 section 3.3.1, and also some other 22 * Handles dates as defined by RFC 2616 section 3.3.1, and also some other
23 * non-standard, but common formats. 23 * non-standard, but common formats.
24 */ 24 */
25 private static $dateFormats = array( 25 private static $dateFormats = [
26 'D, d M Y H:i:s T', 26 'D, d M Y H:i:s T',
27 'D, d-M-y H:i:s T', 27 'D, d-M-y H:i:s T',
28 'D, d-M-Y H:i:s T', 28 'D, d-M-Y H:i:s T',
29 'D, d-m-y H:i:s T', 29 'D, d-m-y H:i:s T',
30 'D, d-m-Y H:i:s T', 30 'D, d-m-Y H:i:s T',
31 'D M j G:i:s Y', 31 'D M j G:i:s Y',
32 'D M d H:i:s Y T', 32 'D M d H:i:s Y T',
33 ); 33 ];
34 34
35 protected $name; 35 protected $name;
36 protected $value; 36 protected $value;
37 protected $expires; 37 protected $expires;
38 protected $path; 38 protected $path;
127 throw new \InvalidArgumentException(sprintf('The cookie string "%s" is not valid.', $parts[0])); 127 throw new \InvalidArgumentException(sprintf('The cookie string "%s" is not valid.', $parts[0]));
128 } 128 }
129 129
130 list($name, $value) = explode('=', array_shift($parts), 2); 130 list($name, $value) = explode('=', array_shift($parts), 2);
131 131
132 $values = array( 132 $values = [
133 'name' => trim($name), 133 'name' => trim($name),
134 'value' => trim($value), 134 'value' => trim($value),
135 'expires' => null, 135 'expires' => null,
136 'path' => '/', 136 'path' => '/',
137 'domain' => '', 137 'domain' => '',
138 'secure' => false, 138 'secure' => false,
139 'httponly' => false, 139 'httponly' => false,
140 'passedRawValue' => true, 140 'passedRawValue' => true,
141 ); 141 ];
142 142
143 if (null !== $url) { 143 if (null !== $url) {
144 if ((false === $urlParts = parse_url($url)) || !isset($urlParts['host'])) { 144 if ((false === $urlParts = parse_url($url)) || !isset($urlParts['host'])) {
145 throw new \InvalidArgumentException(sprintf('The URL "%s" is not valid.', $url)); 145 throw new \InvalidArgumentException(sprintf('The URL "%s" is not valid.', $url));
146 } 146 }
167 $values['httponly'] = true; 167 $values['httponly'] = true;
168 168
169 continue; 169 continue;
170 } 170 }
171 171
172 if (2 === count($elements = explode('=', $part, 2))) { 172 if (2 === \count($elements = explode('=', $part, 2))) {
173 if ('expires' === strtolower($elements[0])) { 173 if ('expires' === strtolower($elements[0])) {
174 $elements[1] = self::parseDate($elements[1]); 174 $elements[1] = self::parseDate($elements[1]);
175 } 175 }
176 176
177 $values[strtolower($elements[0])] = $elements[1]; 177 $values[strtolower($elements[0])] = $elements[1];
191 } 191 }
192 192
193 private static function parseDate($dateValue) 193 private static function parseDate($dateValue)
194 { 194 {
195 // trim single quotes around date if present 195 // trim single quotes around date if present
196 if (($length = strlen($dateValue)) > 1 && "'" === $dateValue[0] && "'" === $dateValue[$length - 1]) { 196 if (($length = \strlen($dateValue)) > 1 && "'" === $dateValue[0] && "'" === $dateValue[$length - 1]) {
197 $dateValue = substr($dateValue, 1, -1); 197 $dateValue = substr($dateValue, 1, -1);
198 } 198 }
199 199
200 foreach (self::$dateFormats as $dateFormat) { 200 foreach (self::$dateFormats as $dateFormat) {
201 if (false !== $date = \DateTime::createFromFormat($dateFormat, $dateValue, new \DateTimeZone('GMT'))) { 201 if (false !== $date = \DateTime::createFromFormat($dateFormat, $dateValue, new \DateTimeZone('GMT'))) {