diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-02-22 10:22:11 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-02-22 15:51:19 +0100 |
commit | 0ee45d3d20ce53db97b6835acb00a95e27ee072d (patch) | |
tree | 61a33428a9e19f1b142e0bf22df97b391ab20b0e | |
parent | a229095af1f70726036c1247a6ee5914b257577d (diff) | |
download | nextcloud-server-0ee45d3d20ce53db97b6835acb00a95e27ee072d.tar.gz nextcloud-server-0ee45d3d20ce53db97b6835acb00a95e27ee072d.zip |
Fix proper types
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
-rw-r--r-- | lib/private/AppFramework/Http/Request.php | 12 | ||||
-rw-r--r-- | lib/private/Server.php | 2 | ||||
-rw-r--r-- | tests/lib/AppFramework/Http/RequestTest.php | 2 |
3 files changed, 12 insertions, 4 deletions
diff --git a/lib/private/AppFramework/Http/Request.php b/lib/private/AppFramework/Http/Request.php index 2294a471045..e6766107cba 100644 --- a/lib/private/AppFramework/Http/Request.php +++ b/lib/private/AppFramework/Http/Request.php @@ -678,7 +678,11 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0. */ public function getHttpProtocol(): string { - $claimedProtocol = strtoupper($this->server['SERVER_PROTOCOL']); + $claimedProtocol = $this->server['SERVER_PROTOCOL']; + + if (\is_string($claimedProtocol)) { + $claimedProtocol = strtoupper($claimedProtocol); + } $validProtocols = [ 'HTTP/1.0', @@ -738,10 +742,14 @@ class Request implements \ArrayAccess, \Countable, IRequest { throw new \Exception("The requested uri($requestUri) cannot be processed by the script '$scriptName')"); } } + if ($name === null) { + $name = ''; + } + if (strpos($pathInfo, '/'.$name) === 0) { $pathInfo = substr($pathInfo, \strlen($name) + 1); } - if (strpos($pathInfo, $name) === 0) { + if ($name !== '' && strpos($pathInfo, $name) === 0) { $pathInfo = substr($pathInfo, \strlen($name)); } if($pathInfo === false || $pathInfo === '/'){ diff --git a/lib/private/Server.php b/lib/private/Server.php index 228f0ab5f97..d586bab15b9 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -814,7 +814,7 @@ class Server extends ServerContainer implements IServerContainer { 'cookies' => $_COOKIE, 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) ? $_SERVER['REQUEST_METHOD'] - : null, + : '', 'urlParams' => $urlParams, ], $this->getSecureRandom(), diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php index cc55e33f354..c6b9719b32a 100644 --- a/tests/lib/AppFramework/Http/RequestTest.php +++ b/tests/lib/AppFramework/Http/RequestTest.php @@ -307,7 +307,7 @@ class RequestTest extends \Test\TestCase { 'method' => 'PUT', 'server' => [ 'CONTENT_TYPE' => 'image/png', - 'CONTENT_LENGTH' => strlen($data) + 'CONTENT_LENGTH' => (string)strlen($data) ], ); |