summaryrefslogtreecommitdiffstats
path: root/core/avatar
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-08-26 17:08:25 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-10-09 11:19:05 +0200
commitc7aef6c36833b1d9bdec9dc30ceb874b8cb93019 (patch)
treee037f244957f18d0182c71532e6d2f7db5158a8f /core/avatar
parent5cb83937faf7a6cf72c932346fcf62073d4b405b (diff)
downloadnextcloud-server-c7aef6c36833b1d9bdec9dc30ceb874b8cb93019.tar.gz
nextcloud-server-c7aef6c36833b1d9bdec9dc30ceb874b8cb93019.zip
Fix uploading avatar and root certs in IE8
Diffstat (limited to 'core/avatar')
-rw-r--r--core/avatar/avatarcontroller.php58
1 files changed, 46 insertions, 12 deletions
diff --git a/core/avatar/avatarcontroller.php b/core/avatar/avatarcontroller.php
index 4841ba00f7a..1604ecf79d1 100644
--- a/core/avatar/avatarcontroller.php
+++ b/core/avatar/avatarcontroller.php
@@ -140,12 +140,21 @@ class AvatarController extends Controller {
$userId = $this->userSession->getUser()->getUID();
$files = $this->request->getUploadedFile('files');
+ $headers = [];
+ if (\OCP\Util::isIE8()) {
+ // due to upload iframe workaround, need to set content-type to text/plain
+ $headers['Content-Type'] = 'text/plain';
+ }
+
if (isset($path)) {
$path = stripslashes($path);
$node = $this->userFolder->get($path);
if ($node->getSize() > 20*1024*1024) {
- return new DataResponse(['data' => ['message' => $this->l->t('File is too big')]],
- Http::STATUS_BAD_REQUEST);
+ return new DataResponse(
+ ['data' => ['message' => $this->l->t('File is too big')]],
+ Http::STATUS_BAD_REQUEST,
+ $headers
+ );
}
$content = $node->getContent();
} elseif (!is_null($files)) {
@@ -155,20 +164,29 @@ class AvatarController extends Controller {
!\OC\Files\Filesystem::isFileBlacklisted($files['tmp_name'][0])
) {
if ($files['size'][0] > 20*1024*1024) {
- return new DataResponse(['data' => ['message' => $this->l->t('File is too big')]],
- Http::STATUS_BAD_REQUEST);
+ return new DataResponse(
+ ['data' => ['message' => $this->l->t('File is too big')]],
+ Http::STATUS_BAD_REQUEST,
+ $headers
+ );
}
$this->cache->set('avatar_upload', file_get_contents($files['tmp_name'][0]), 7200);
$content = $this->cache->get('avatar_upload');
unlink($files['tmp_name'][0]);
} else {
- return new DataResponse(['data' => ['message' => $this->l->t('Invalid file provided')]],
- Http::STATUS_BAD_REQUEST);
+ return new DataResponse(
+ ['data' => ['message' => $this->l->t('Invalid file provided')]],
+ Http::STATUS_BAD_REQUEST,
+ $headers
+ );
}
} else {
//Add imgfile
- return new DataResponse(['data' => ['message' => $this->l->t('No image or file provided')]],
- Http::STATUS_BAD_REQUEST);
+ return new DataResponse(
+ ['data' => ['message' => $this->l->t('No image or file provided')]],
+ Http::STATUS_BAD_REQUEST,
+ $headers
+ );
}
try {
@@ -179,16 +197,32 @@ class AvatarController extends Controller {
if ($image->valid()) {
$mimeType = $image->mimeType();
if ($mimeType !== 'image/jpeg' && $mimeType !== 'image/png') {
- return new DataResponse(['data' => ['message' => $this->l->t('Unknown filetype')]]);
+ return new DataResponse(
+ ['data' => ['message' => $this->l->t('Unknown filetype')]],
+ Http::STATUS_OK,
+ $headers
+ );
}
$this->cache->set('tmpAvatar', $image->data(), 7200);
- return new DataResponse(['data' => 'notsquare']);
+ return new DataResponse(
+ ['data' => 'notsquare'],
+ Http::STATUS_OK,
+ $headers
+ );
} else {
- return new DataResponse(['data' => ['message' => $this->l->t('Invalid image')]]);
+ return new DataResponse(
+ ['data' => ['message' => $this->l->t('Invalid image')]],
+ Http::STATUS_OK,
+ $headers
+ );
}
} catch (\Exception $e) {
- return new DataResponse(['data' => ['message' => $e->getMessage()]]);
+ return new DataResponse(
+ ['data' => ['message' => $e->getMessage()]],
+ Http::STATUS_OK,
+ $headers
+ );
}
}