Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/browser-kit/CookieJar.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 |
---|---|
16 * | 16 * |
17 * @author Fabien Potencier <fabien@symfony.com> | 17 * @author Fabien Potencier <fabien@symfony.com> |
18 */ | 18 */ |
19 class CookieJar | 19 class CookieJar |
20 { | 20 { |
21 protected $cookieJar = array(); | 21 protected $cookieJar = []; |
22 | 22 |
23 public function set(Cookie $cookie) | 23 public function set(Cookie $cookie) |
24 { | 24 { |
25 $this->cookieJar[$cookie->getDomain()][$cookie->getPath()][$cookie->getName()] = $cookie; | 25 $this->cookieJar[$cookie->getDomain()][$cookie->getPath()][$cookie->getName()] = $cookie; |
26 } | 26 } |
82 if (empty($domain)) { | 82 if (empty($domain)) { |
83 // an empty domain means any domain | 83 // an empty domain means any domain |
84 // this should never happen but it allows for a better BC | 84 // this should never happen but it allows for a better BC |
85 $domains = array_keys($this->cookieJar); | 85 $domains = array_keys($this->cookieJar); |
86 } else { | 86 } else { |
87 $domains = array($domain); | 87 $domains = [$domain]; |
88 } | 88 } |
89 | 89 |
90 foreach ($domains as $domain) { | 90 foreach ($domains as $domain) { |
91 unset($this->cookieJar[$domain][$path][$name]); | 91 unset($this->cookieJar[$domain][$path][$name]); |
92 | 92 |
103 /** | 103 /** |
104 * Removes all the cookies from the jar. | 104 * Removes all the cookies from the jar. |
105 */ | 105 */ |
106 public function clear() | 106 public function clear() |
107 { | 107 { |
108 $this->cookieJar = array(); | 108 $this->cookieJar = []; |
109 } | 109 } |
110 | 110 |
111 /** | 111 /** |
112 * Updates the cookie jar from a response Set-Cookie headers. | 112 * Updates the cookie jar from a response Set-Cookie headers. |
113 * | 113 * |
114 * @param array $setCookies Set-Cookie headers from an HTTP response | 114 * @param array $setCookies Set-Cookie headers from an HTTP response |
115 * @param string $uri The base URL | 115 * @param string $uri The base URL |
116 */ | 116 */ |
117 public function updateFromSetCookie(array $setCookies, $uri = null) | 117 public function updateFromSetCookie(array $setCookies, $uri = null) |
118 { | 118 { |
119 $cookies = array(); | 119 $cookies = []; |
120 | 120 |
121 foreach ($setCookies as $cookie) { | 121 foreach ($setCookies as $cookie) { |
122 foreach (explode(',', $cookie) as $i => $part) { | 122 foreach (explode(',', $cookie) as $i => $part) { |
123 if (0 === $i || preg_match('/^(?P<token>\s*[0-9A-Za-z!#\$%\&\'\*\+\-\.^_`\|~]+)=/', $part)) { | 123 if (0 === $i || preg_match('/^(?P<token>\s*[0-9A-Za-z!#\$%\&\'\*\+\-\.^_`\|~]+)=/', $part)) { |
124 $cookies[] = ltrim($part); | 124 $cookies[] = ltrim($part); |
125 } else { | 125 } else { |
126 $cookies[count($cookies) - 1] .= ','.$part; | 126 $cookies[\count($cookies) - 1] .= ','.$part; |
127 } | 127 } |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
131 foreach ($cookies as $cookie) { | 131 foreach ($cookies as $cookie) { |
155 */ | 155 */ |
156 public function all() | 156 public function all() |
157 { | 157 { |
158 $this->flushExpiredCookies(); | 158 $this->flushExpiredCookies(); |
159 | 159 |
160 $flattenedCookies = array(); | 160 $flattenedCookies = []; |
161 foreach ($this->cookieJar as $path) { | 161 foreach ($this->cookieJar as $path) { |
162 foreach ($path as $cookies) { | 162 foreach ($path as $cookies) { |
163 foreach ($cookies as $cookie) { | 163 foreach ($cookies as $cookie) { |
164 $flattenedCookies[] = $cookie; | 164 $flattenedCookies[] = $cookie; |
165 } | 165 } |
179 */ | 179 */ |
180 public function allValues($uri, $returnsRawValue = false) | 180 public function allValues($uri, $returnsRawValue = false) |
181 { | 181 { |
182 $this->flushExpiredCookies(); | 182 $this->flushExpiredCookies(); |
183 | 183 |
184 $parts = array_replace(array('path' => '/'), parse_url($uri)); | 184 $parts = array_replace(['path' => '/'], parse_url($uri)); |
185 $cookies = array(); | 185 $cookies = []; |
186 foreach ($this->cookieJar as $domain => $pathCookies) { | 186 foreach ($this->cookieJar as $domain => $pathCookies) { |
187 if ($domain) { | 187 if ($domain) { |
188 $domain = '.'.ltrim($domain, '.'); | 188 $domain = '.'.ltrim($domain, '.'); |
189 if ($domain != substr('.'.$parts['host'], -strlen($domain))) { | 189 if ($domain != substr('.'.$parts['host'], -\strlen($domain))) { |
190 continue; | 190 continue; |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 foreach ($pathCookies as $path => $namedCookies) { | 194 foreach ($pathCookies as $path => $namedCookies) { |
195 if ($path != substr($parts['path'], 0, strlen($path))) { | 195 if ($path != substr($parts['path'], 0, \strlen($path))) { |
196 continue; | 196 continue; |
197 } | 197 } |
198 | 198 |
199 foreach ($namedCookies as $cookie) { | 199 foreach ($namedCookies as $cookie) { |
200 if ($cookie->isSecure() && 'https' != $parts['scheme']) { | 200 if ($cookie->isSecure() && 'https' != $parts['scheme']) { |