Skip to content

Commit ba8296e

Browse files
Fix CVE-2019-10913 issue in symfony/http-foundation
1 parent 5b5df2e commit ba8296e

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

overrides/symfony/http-foundation/Request.php

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,22 +1348,37 @@ public function setMethod($method)
13481348
*/
13491349
public function getMethod()
13501350
{
1351-
if (null === $this->method) {
1352-
$this->method = strtoupper($this->server->get('REQUEST_METHOD', 'GET'));
1353-
1354-
if ('POST' === $this->method) {
1355-
if ($method = $this->headers->get('X-HTTP-METHOD-OVERRIDE')) {
1356-
$this->method = strtoupper($method);
1357-
} elseif (self::$httpMethodParameterOverride) {
1358-
$method = $this->request->get('_method', $this->query->get('_method', 'POST'));
1359-
if (\is_string($method)) {
1360-
$this->method = strtoupper($method);
1361-
}
1362-
}
1363-
}
1351+
if (null !== $this->method) {
1352+
return $this->method;
1353+
}
1354+
1355+
$this->method = strtoupper($this->server->get('REQUEST_METHOD', 'GET'));
1356+
1357+
if ('POST' !== $this->method) {
1358+
return $this->method;
1359+
}
1360+
1361+
$method = $this->headers->get('X-HTTP-METHOD-OVERRIDE');
1362+
1363+
if (!$method && self::$httpMethodParameterOverride) {
1364+
$method = $this->request->get('_method', $this->query->get('_method', 'POST'));
1365+
}
1366+
1367+
if (!\is_string($method)) {
1368+
return $this->method;
1369+
}
1370+
1371+
$method = strtoupper($method);
1372+
1373+
if (\in_array($method, ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'PATCH', 'PURGE', 'TRACE'], true)) {
1374+
return $this->method = $method;
1375+
}
1376+
1377+
if (!preg_match('/^[A-Z]++$/D', $method)) {
1378+
throw new SuspiciousOperationException(sprintf('Invalid method override "%s".', $method));
13641379
}
13651380

1366-
return $this->method;
1381+
return $this->method = $method;
13671382
}
13681383

13691384
/**

0 commit comments

Comments
 (0)