summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2017-03-10 18:12:55 +0100
committerGitHub <noreply@github.com>2017-03-10 18:12:55 +0100
commit1045bf4a2bd6777cfc6ee818f562db7145eae70a (patch)
tree5e9bfb3d217787f17ccf71aa2e43cb42232bbb8e
parent350aa8d8d242115f83523b51f72077d705a1a62a (diff)
parentf6ef024159b66a47109a83a4c98ba59c4bda9aaf (diff)
downloadnextcloud-server-1045bf4a2bd6777cfc6ee818f562db7145eae70a.tar.gz
nextcloud-server-1045bf4a2bd6777cfc6ee818f562db7145eae70a.zip
Merge pull request #3793 from stefan-squareweave/master
Correct incorrectly typed X-OC-Mtime header
-rw-r--r--apps/dav/lib/Connector/Sabre/File.php7
-rw-r--r--apps/files/js/file-upload.js2
2 files changed, 7 insertions, 2 deletions
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php
index d0826ee5a8c..391d42393f5 100644
--- a/apps/dav/lib/Connector/Sabre/File.php
+++ b/apps/dav/lib/Connector/Sabre/File.php
@@ -206,7 +206,12 @@ 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 ($this->fileView->touch($this->path, $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);
+ if ($this->fileView->touch($this->path, $mtime)) {
header('X-OC-MTime: accepted');
}
}
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index c93abd5244d..6f9fd9aafea 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -222,7 +222,7 @@ OC.FileUpload.prototype = {
if (file.lastModified) {
// preserve timestamp
- this.data.headers['X-OC-Mtime'] = file.lastModified / 1000;
+ this.data.headers['X-OC-Mtime'] = (file.lastModified / 1000).toFixed(0);
}
var userName = this.uploader.filesClient.getUserName();