Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2017-09-21 12:36:27 +0300
committerJulius Härtl <jus@bitgrid.net>2017-10-03 16:34:44 +0300
commitf15e85c4f50b6c9e77742e15f8291a8628a28ef7 (patch)
tree6c295017a74b581e6377a16de92a103fbc78b601 /apps/theming/lib/Controller
parent9651c1abffa0134b11b7637de76ceb4e3ffae79e (diff)
Theming: Add tests for mimetype and upload error checks
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/theming/lib/Controller')
-rw-r--r--apps/theming/lib/Controller/ThemingController.php23
1 files changed, 12 insertions, 11 deletions
diff --git a/apps/theming/lib/Controller/ThemingController.php b/apps/theming/lib/Controller/ThemingController.php
index e6aa3a380b7..ccc2634ec14 100644
--- a/apps/theming/lib/Controller/ThemingController.php
+++ b/apps/theming/lib/Controller/ThemingController.php
@@ -208,16 +208,16 @@ class ThemingController extends Controller {
$newLogo = $this->request->getUploadedFile('uploadlogo');
$newBackgroundLogo = $this->request->getUploadedFile('upload-login-background');
$error = null;
- $phpFileUploadErrors = array(
- 0 => $this->l10n->t('There is no error, the file uploaded with success'),
- 1 => $this->l10n->t('The uploaded file exceeds the upload_max_filesize directive in php.ini'),
- 2 => $this->l10n->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'),
- 3 => $this->l10n->t('The uploaded file was only partially uploaded'),
- 4 => $this->l10n->t('No file was uploaded'),
- 6 => $this->l10n->t('Missing a temporary folder'),
- 7 => $this->l10n->t('Failed to write file to disk.'),
- 8 => $this->l10n->t('A PHP extension stopped the file upload.'),
- );
+ $phpFileUploadErrors = [
+ UPLOAD_ERR_OK => $this->l10n->t('There is no error, the file uploaded with success'),
+ UPLOAD_ERR_INI_SIZE => $this->l10n->t('The uploaded file exceeds the upload_max_filesize directive in php.ini'),
+ UPLOAD_ERR_FORM_SIZE => $this->l10n->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'),
+ UPLOAD_ERR_PARTIAL => $this->l10n->t('The uploaded file was only partially uploaded'),
+ UPLOAD_ERR_NO_FILE => $this->l10n->t('No file was uploaded'),
+ UPLOAD_ERR_NO_TMP_DIR => $this->l10n->t('Missing a temporary folder'),
+ UPLOAD_ERR_CANT_WRITE => $this->l10n->t('Failed to write file to disk.'),
+ UPLOAD_ERR_EXTENSION => $this->l10n->t('A PHP extension stopped the file upload.'),
+ ];
if (empty($newLogo) && empty($newBackgroundLogo)) {
$error = $this->l10n->t('No file uploaded');
}
@@ -233,7 +233,8 @@ class ThemingController extends Controller {
[
'data' => [
'message' => $error
- ]
+ ],
+ 'status' => 'failure',
],
Http::STATUS_UNPROCESSABLE_ENTITY
);