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

github.com/nextcloud/files_texteditor.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-06-09 20:07:13 +0300
committerJoas Schilling <nickvergessen@owncloud.com>2015-06-10 11:34:16 +0300
commit51ebcfbdfe7ad33a675f00fb3131b3c6a033d1c0 (patch)
treeeded5b85b39a2ad9b6fe91cf0584610d515bc104
parent4861a0d7b6c4f81b895dc7a228cd4da29da8530d (diff)
Allow opening of empty files ('', '0', 0)
-rw-r--r--controller/filehandlingcontroller.php8
-rw-r--r--tests/controller/filehandlingcontrollertest.php2
2 files changed, 6 insertions, 4 deletions
diff --git a/controller/filehandlingcontroller.php b/controller/filehandlingcontroller.php
index 7fcc502..efb2283 100644
--- a/controller/filehandlingcontroller.php
+++ b/controller/filehandlingcontroller.php
@@ -75,11 +75,11 @@ class FileHandlingController extends Controller{
try {
if (!empty($filename)) {
$path = $dir . '/' . $filename;
- $writable = $this->view->isUpdatable($path);
- $mime = $this->view->getMimeType($path);
- $mtime = $this->view->filemtime($path);
$filecontents = $this->view->file_get_contents($path);
- if ($filecontents) {
+ if ($filecontents !== false) {
+ $writable = $this->view->isUpdatable($path);
+ $mime = $this->view->getMimeType($path);
+ $mtime = $this->view->filemtime($path);
$encoding = mb_detect_encoding($filecontents . "a", "UTF-8, WINDOWS-1252, ISO-8859-15, ISO-8859-1, ASCII", true);
if ($encoding == "") {
// set default encoding if it couldn't be detected
diff --git a/tests/controller/filehandlingcontrollertest.php b/tests/controller/filehandlingcontrollertest.php
index 34cfa02..901e904 100644
--- a/tests/controller/filehandlingcontrollertest.php
+++ b/tests/controller/filehandlingcontrollertest.php
@@ -109,6 +109,8 @@ class FileHandlingControllerTest extends TestCase {
public function dataTestLoad() {
return array(
array('test.txt', 'file content', 200, ''),
+ array('test.txt', '', 200, ''),
+ array('test.txt', '0', 200, ''),
array('', 'file content', 400, 'Invalid file path supplied.'),
array('test.txt', false, 400, 'Can not read the file.'),
);