Skip to content

Commit

Permalink
Correctly process a POST with no Content-Type specified
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Feb 4, 2021
1 parent 4258420 commit a5d3496
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/DAV/Browser/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ public function httpGet(RequestInterface $request, ResponseInterface $response)
public function httpPOST(RequestInterface $request, ResponseInterface $response)
{
$contentType = $request->getHeader('Content-Type');
if (!\is_string($contentType)) {
return;
}
list($contentType) = explode(';', $contentType);
if ('application/x-www-form-urlencoded' !== $contentType &&
'multipart/form-data' !== $contentType) {
Expand Down
9 changes: 9 additions & 0 deletions tests/Sabre/DAV/Browser/PluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ public function testPostOtherContentType()
$this->assertEquals(501, $this->response->status);
}

public function testPostNoContentType()
{
$request = new HTTP\Request('POST', '/', []);
$this->server->httpRequest = $request;
$this->server->exec();

$this->assertEquals(501, $this->response->status);
}

public function testPostNoSabreAction()
{
$request = new HTTP\Request('POST', '/', ['Content-Type' => 'application/x-www-form-urlencoded']);
Expand Down

0 comments on commit a5d3496

Please sign in to comment.