Update dependencies, fix potential WOPI bug

This commit is contained in:
bohwaz 2024-01-31 14:25:14 +01:00
parent b1b49ef783
commit ea4d8b459d
2 changed files with 8 additions and 5 deletions

View file

@ -541,6 +541,8 @@ class Server
fseek($file['resource'], 0, SEEK_SET); fseek($file['resource'], 0, SEEK_SET);
} }
http_response_code(200);
if (($start || $end) && $seek === 0) { if (($start || $end) && $seek === 0) {
if (null !== $end && $end > $length) { if (null !== $end && $end > $length) {
header('Content-Range: bytes */' . $length, true); header('Content-Range: bytes */' . $length, true);
@ -1084,7 +1086,7 @@ class Server
$set_time_name = $name; $set_time_name = $name;
} }
$prefix .= sprintf(">\n<d:response>\n <d:href>%s</d:href>\n", htmlspecialchars($url, ENT_XML1)); $prefix .= sprintf(">\n<d:response>\n <d:href>%s</d:href>\n", htmlspecialchars($uri, ENT_XML1));
// http_response_code doesn't know the 207 status code // http_response_code doesn't know the 207 status code
header('HTTP/1.1 207 Multi-Status', true); header('HTTP/1.1 207 Multi-Status', true);
@ -1366,7 +1368,7 @@ class Server
throw new Exception(sprintf('Invalid URI, "%s" is outside of scope "%s"', $uri, $this->base_uri), 400); throw new Exception(sprintf('Invalid URI, "%s" is outside of scope "%s"', $uri, $this->base_uri), 400);
} }
$uri = $this->validateURI(); $uri = $this->validateURI($uri);
$uri = substr($uri, strlen($this->base_uri)); $uri = substr($uri, strlen($this->base_uri));
$uri = $this->_prefix($uri); $uri = $this->_prefix($uri);

View file

@ -103,6 +103,10 @@ class WOPI
elseif ($action == 'contents' && $method == 'POST') { elseif ($action == 'contents' && $method == 'POST') {
$this->server->log('WOPI: => PutFile'); $this->server->log('WOPI: => PutFile');
$this->server->http_put($uri); $this->server->http_put($uri);
// In WOPI, HTTP response code 201/204 is not accepted, only 200
// or Collabora will fail saving
http_response_code(200);
} }
// CheckFileInfo // CheckFileInfo
elseif (!$action && $method == 'GET') { elseif (!$action && $method == 'GET') {
@ -112,9 +116,6 @@ class WOPI
else { else {
throw new Exception('Invalid URI', 404); throw new Exception('Invalid URI', 404);
} }
$this->server->log('WOPI: <= 200');
http_response_code(200); // This is required for Collabora
} }
catch (Exception $e) { catch (Exception $e) {
$this->server->log('WOPI: => %d: %s', $e->getCode(), $e->getMessage()); $this->server->log('WOPI: => %d: %s', $e->getCode(), $e->getMessage());