summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/Connector/Sabre/File.php
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2017-11-27 19:41:25 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2017-11-27 20:37:51 +0100
commit01e346b2ae92446e3d86cd54381fb54a5c680fca (patch)
tree37bc930b23714aaf48978a65c812f40f7b0fb87c /apps/dav/lib/Connector/Sabre/File.php
parent892d2630fe099cb4845d9bcf740e9683c257d5d3 (diff)
downloadnextcloud-server-01e346b2ae92446e3d86cd54381fb54a5c680fca.tar.gz
nextcloud-server-01e346b2ae92446e3d86cd54381fb54a5c680fca.zip
Ensure that X-OC-MTime header is an integer also with chunked uploads
This commit extends the changes introduced in pull request #3793 also to chunked uploads. The "sanitizeMTime" method name is the same used in the equivalent pull request to this one from ownCloud (28066). Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/dav/lib/Connector/Sabre/File.php')
-rw-r--r--apps/dav/lib/Connector/Sabre/File.php17
1 files changed, 11 insertions, 6 deletions
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php
index f172bde5f1f..b9d55cc454f 100644
--- a/apps/dav/lib/Connector/Sabre/File.php
+++ b/apps/dav/lib/Connector/Sabre/File.php
@@ -210,11 +210,7 @@ class File extends Node implements IFile {
// allow sync clients to send the mtime along in a header
$request = \OC::$server->getRequest();
if (isset($request->server['HTTP_X_OC_MTIME'])) {
- $mtimeStr = $request->server['HTTP_X_OC_MTIME'];
- if (!is_numeric($mtimeStr)) {
- throw new \InvalidArgumentException('X-OC-Mtime header must be an integer (unix timestamp).');
- }
- $mtime = intval($mtimeStr);
+ $mtime = $this->sanitizeMtime($request->server['HTTP_X_OC_MTIME']);
if ($this->fileView->touch($this->path, $mtime)) {
header('X-OC-MTime: accepted');
}
@@ -472,7 +468,8 @@ class File extends Node implements IFile {
// allow sync clients to send the mtime along in a header
$request = \OC::$server->getRequest();
if (isset($request->server['HTTP_X_OC_MTIME'])) {
- if ($targetStorage->touch($targetInternalPath, $request->server['HTTP_X_OC_MTIME'])) {
+ $mtime = $this->sanitizeMtime($request->server['HTTP_X_OC_MTIME']);
+ if ($targetStorage->touch($targetInternalPath, $mtime)) {
header('X-OC-MTime: accepted');
}
}
@@ -570,6 +567,14 @@ class File extends Node implements IFile {
throw new \Sabre\DAV\Exception($e->getMessage(), 0, $e);
}
+ private function sanitizeMtime($mtimeFromRequest) {
+ if (!is_numeric($mtimeFromRequest)) {
+ throw new \InvalidArgumentException('X-OC-MTime header must be an integer (unix timestamp).');
+ }
+
+ return intval($mtimeFromRequest);
+ }
+
/**
* Get the checksum for this file
*