From 730c80ff9c83ff1b027ab804ecad599fbcaf7bd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 7 Oct 2013 15:11:47 +0200 Subject: [PATCH 01/11] adding additional exceptions for special cases where creating a file might not be allowed --- .../sabre/exception/entitytoolarge.php | 23 +++++++++++++++++++ .../sabre/exception/unsupportedmediatype.php | 22 ++++++++++++++++++ lib/private/connector/sabre/file.php | 7 ++++++ lib/public/files/entitytoolargeexception.php | 11 +++++++++ lib/public/files/invalidcontentexception.php | 11 +++++++++ lib/public/files/invalidpathexception.php | 11 +++++++++ 6 files changed, 85 insertions(+) create mode 100644 lib/private/connector/sabre/exception/entitytoolarge.php create mode 100644 lib/private/connector/sabre/exception/unsupportedmediatype.php create mode 100644 lib/public/files/entitytoolargeexception.php create mode 100644 lib/public/files/invalidcontentexception.php create mode 100644 lib/public/files/invalidpathexception.php diff --git a/lib/private/connector/sabre/exception/entitytoolarge.php b/lib/private/connector/sabre/exception/entitytoolarge.php new file mode 100644 index 00000000000..aa9b37a0496 --- /dev/null +++ b/lib/private/connector/sabre/exception/entitytoolarge.php @@ -0,0 +1,23 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCP\Files; + +class EntityTooLargeException extends \Exception {} diff --git a/lib/public/files/invalidcontentexception.php b/lib/public/files/invalidcontentexception.php new file mode 100644 index 00000000000..184ec4d06d6 --- /dev/null +++ b/lib/public/files/invalidcontentexception.php @@ -0,0 +1,11 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCP\Files; + +class InvalidContentException extends \Exception {} diff --git a/lib/public/files/invalidpathexception.php b/lib/public/files/invalidpathexception.php new file mode 100644 index 00000000000..36090ae5b48 --- /dev/null +++ b/lib/public/files/invalidpathexception.php @@ -0,0 +1,11 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OCP\Files; + +class InvalidPathException extends \Exception {} From 7c6ed6ab33e8487d6de135b5e956a82685bf4463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 8 Oct 2013 15:03:24 +0200 Subject: [PATCH 02/11] catch exceptions while uploading and pass on the error message --- apps/files/ajax/upload.php | 51 ++++++++++++++++++++---------------- apps/files/js/file-upload.js | 2 +- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index 0920bf62109..45fb17de94a 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -110,30 +110,35 @@ if (strpos($dir, '..') === false) { || (isset($_POST['resolution']) && $_POST['resolution']==='replace') ) { // upload and overwrite file - if (is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) { - - // updated max file size after upload - $storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir); - - $meta = \OC\Files\Filesystem::getFileInfo($target); - if ($meta === false) { - $error = $l->t('Upload failed. Could not get file info.'); + try + { + if (is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) { + + // updated max file size after upload + $storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir); + + $meta = \OC\Files\Filesystem::getFileInfo($target); + if ($meta === false) { + $error = $l->t('Upload failed. Could not get file info.'); + } else { + $result[] = array('status' => 'success', + 'mime' => $meta['mimetype'], + 'mtime' => $meta['mtime'], + 'size' => $meta['size'], + 'id' => $meta['fileid'], + 'name' => basename($target), + 'originalname' => $files['tmp_name'][$i], + 'uploadMaxFilesize' => $maxUploadFileSize, + 'maxHumanFilesize' => $maxHumanFileSize, + 'permissions' => $meta['permissions'], + ); + } + } else { - $result[] = array('status' => 'success', - 'mime' => $meta['mimetype'], - 'mtime' => $meta['mtime'], - 'size' => $meta['size'], - 'id' => $meta['fileid'], - 'name' => basename($target), - 'originalname' => $files['tmp_name'][$i], - 'uploadMaxFilesize' => $maxUploadFileSize, - 'maxHumanFilesize' => $maxHumanFileSize, - 'permissions' => $meta['permissions'], - ); + $error = $l->t('Upload failed. Could not find uploaded file'); } - - } else { - $error = $l->t('Upload failed. Could not find uploaded file'); + } catch(Exception $ex) { + $error = $ex->getMessage(); } } else { @@ -164,5 +169,5 @@ if ($error === false) { OCP\JSON::encodedPrint($result); exit(); } else { - OCP\JSON::error(array('data' => array_merge(array('message' => $error), $storageStats))); + OCP\JSON::error(array(array('data' => array_merge(array('message' => $error), $storageStats)))); } diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index b52221ac1fc..88d5a05107f 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -365,7 +365,7 @@ $(document).ready(function() { } else if (result[0].status !== 'success') { //delete data.jqXHR; data.textStatus = 'servererror'; - data.errorThrown = result.data.message; // error message has been translated on server + data.errorThrown = result[0].data.message; // error message has been translated on server var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload'); fu._trigger('fail', e, data); } From caa27824a94e3af757ea33b01b5682ef963ae714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 8 Oct 2013 15:04:31 +0200 Subject: [PATCH 03/11] catch specific file exceptions and convert them to proper http status code via webdav --- lib/private/connector/sabre/file.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php index 3c19da7c618..84154ee855a 100644 --- a/lib/private/connector/sabre/file.php +++ b/lib/private/connector/sabre/file.php @@ -87,14 +87,21 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D throw new Sabre_DAV_Exception(); } } catch (\OCP\Files\NotPermittedException $e) { - throw new Sabre_DAV_Exception_Forbidden(); + // a more general case - due to whatever reason the content could not be written + throw new Sabre_DAV_Exception_Forbidden($e->getMessage()); + } catch (\OCP\Files\EntityTooLargeException $e) { - throw new OC_Connector_Sabre_Exception_EntityTooLarge(); + // the file is too big to be stored + throw new OC_Connector_Sabre_Exception_EntityTooLarge($e->getMessage()); + } catch (\OCP\Files\InvalidContentException $e) { - throw new OC_Connector_Sabre_Exception_UnsupportedMediaType(); + // the file content is not permitted + throw new OC_Connector_Sabre_Exception_UnsupportedMediaType($e->getMessage()); + } catch (\OCP\Files\InvalidPathException $e) { - // TODO: add specific exception here - throw new Sabre_DAV_Exception_Forbidden(); + // the path for the file was not valid + // TODO: find proper http status code for this case + throw new Sabre_DAV_Exception_Forbidden($e->getMessage()); } // rename to correct path From 3f27fefdbe1342701161bf0949dd719f34dab76d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 8 Oct 2013 15:40:42 +0200 Subject: [PATCH 04/11] fixing status code and formatting --- .../sabre/exception/entitytoolarge.php | 19 +++++++++---------- .../sabre/exception/unsupportedmediatype.php | 16 ++++++++-------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/private/connector/sabre/exception/entitytoolarge.php b/lib/private/connector/sabre/exception/entitytoolarge.php index aa9b37a0496..2bda51f2f3e 100644 --- a/lib/private/connector/sabre/exception/entitytoolarge.php +++ b/lib/private/connector/sabre/exception/entitytoolarge.php @@ -1,23 +1,22 @@ Date: Fri, 11 Oct 2013 00:15:32 +0200 Subject: [PATCH 05/11] Fixed delete icon alignment in IE8 Removed old inline CSS that forced every td to have position:static in the files app. (#5056) --- apps/files/templates/index.php | 2 +- apps/files_trashbin/templates/index.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index ebdca097e74..1c07d14ea8a 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -1,4 +1,4 @@ - +
diff --git a/apps/files_trashbin/templates/index.php b/apps/files_trashbin/templates/index.php index 9b01a2589a5..17045313d6c 100644 --- a/apps/files_trashbin/templates/index.php +++ b/apps/files_trashbin/templates/index.php @@ -1,4 +1,4 @@ - +
From 39b150921de06dceb06f45ba271ab97015f369c9 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 11 Oct 2013 14:10:00 +0200 Subject: [PATCH 06/11] Moved IE8 inline styles in files.css --- apps/files/css/files.css | 3 +++ apps/files/templates/index.php | 1 - apps/files_trashbin/templates/index.php | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/files/css/files.css b/apps/files/css/files.css index cbf34279f54..7c6778af62f 100644 --- a/apps/files/css/files.css +++ b/apps/files/css/files.css @@ -178,6 +178,9 @@ table td.filename .nametext { table td.filename .uploadtext { font-weight:normal; margin-left:.5em; } table td.filename form { font-size:.85em; margin-left:3em; margin-right:3em; } +.ie8 input[type="checkbox"]{ + padding: 0; +} /* File checkboxes */ #fileList tr td.filename>input[type="checkbox"]:first-child { diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 1c07d14ea8a..32a59f1e1a6 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -1,4 +1,3 @@ -
diff --git a/apps/files_trashbin/templates/index.php b/apps/files_trashbin/templates/index.php index 17045313d6c..15ba074e45e 100644 --- a/apps/files_trashbin/templates/index.php +++ b/apps/files_trashbin/templates/index.php @@ -1,4 +1,3 @@ -
From 4b2bb117168baf24ad14b8e27fa78200db223c5a Mon Sep 17 00:00:00 2001 From: raghunayyar Date: Fri, 11 Oct 2013 18:42:02 +0530 Subject: [PATCH 07/11] Removes the Bogus Label --- settings/templates/personal.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/settings/templates/personal.php b/settings/templates/personal.php index d10413dac3d..854cc93b4f4 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -113,9 +113,6 @@ if($_['passwordChangeSupported']) { - - - + - +