summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2013-04-23 07:17:36 -0700
committerLukas Reschke <lukas@statuscode.ch>2013-04-23 07:17:36 -0700
commit495868497c4ea38e47d979dfd0db8bd879ac489a (patch)
tree01c164351c389760f2f21295f2e3fdcb7fd226c8
parent05ab9d2de7f2c5181eda2174a2e2adb1cc214196 (diff)
parent3c90625ef114aa8005ab675c614dfeb919a6ac84 (diff)
downloadnextcloud-server-495868497c4ea38e47d979dfd0db8bd879ac489a.tar.gz
nextcloud-server-495868497c4ea38e47d979dfd0db8bd879ac489a.zip
Merge pull request #3077 from owncloud/rename-checksourcepath
Files: also check if the source path is valid when doing a rename or copy operation
-rw-r--r--lib/files/view.php38
1 files changed, 23 insertions, 15 deletions
diff --git a/lib/files/view.php b/lib/files/view.php
index f607bb59aac..0da104c107e 100644
--- a/lib/files/view.php
+++ b/lib/files/view.php
@@ -245,13 +245,13 @@ class View {
if (!is_null($mtime) and !is_numeric($mtime)) {
$mtime = strtotime($mtime);
}
-
+
$hooks = array('touch');
-
+
if (!$this->file_exists($path)) {
$hooks[] = 'write';
}
-
+
return $this->basicOperation('touch', $path, $hooks, $mtime);
}
@@ -263,11 +263,12 @@ class View {
if (is_resource($data)) { //not having to deal with streams in file_put_contents makes life easier
$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path));
if (\OC_FileProxy::runPreProxies('file_put_contents', $absolutePath, $data)
- && Filesystem::isValidPath($path)) {
+ && Filesystem::isValidPath($path)
+ ) {
$path = $this->getRelativePath($absolutePath);
$exists = $this->file_exists($path);
$run = true;
- if ($this->fakeRoot == Filesystem::getRoot() && ! Cache\Scanner::isIgnoredFile($path) ) {
+ if ($this->fakeRoot == Filesystem::getRoot() && !Cache\Scanner::isIgnoredFile($path)) {
if (!$exists) {
\OC_Hook::emit(
Filesystem::CLASSNAME,
@@ -295,7 +296,7 @@ class View {
list ($count, $result) = \OC_Helper::streamCopy($data, $target);
fclose($target);
fclose($data);
- if ($this->fakeRoot == Filesystem::getRoot() && ! Cache\Scanner::isIgnoredFile($path) ) {
+ if ($this->fakeRoot == Filesystem::getRoot() && !Cache\Scanner::isIgnoredFile($path)) {
if (!$exists) {
\OC_Hook::emit(
Filesystem::CLASSNAME,
@@ -335,8 +336,11 @@ class View {
$postFix2 = (substr($path2, -1, 1) === '/') ? '/' : '';
$absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($path1));
$absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($path2));
- if (\OC_FileProxy::runPreProxies('rename', $absolutePath1, $absolutePath2)
- and Filesystem::isValidPath($path2)) {
+ if (
+ \OC_FileProxy::runPreProxies('rename', $absolutePath1, $absolutePath2)
+ and Filesystem::isValidPath($path2)
+ and Filesystem::isValidPath($path1)
+ ) {
$path1 = $this->getRelativePath($absolutePath1);
$path2 = $this->getRelativePath($absolutePath2);
@@ -396,7 +400,11 @@ class View {
$postFix2 = (substr($path2, -1, 1) === '/') ? '/' : '';
$absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($path1));
$absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($path2));
- if (\OC_FileProxy::runPreProxies('copy', $absolutePath1, $absolutePath2) and Filesystem::isValidPath($path2)) {
+ if (
+ \OC_FileProxy::runPreProxies('copy', $absolutePath1, $absolutePath2)
+ and Filesystem::isValidPath($path2)
+ and Filesystem::isValidPath($path1)
+ ) {
$path1 = $this->getRelativePath($absolutePath1);
$path2 = $this->getRelativePath($absolutePath2);
@@ -627,7 +635,7 @@ class View {
private function runHooks($hooks, $path, $post = false) {
$prefix = ($post) ? 'post_' : '';
$run = true;
- if (Filesystem::$loaded and $this->fakeRoot == Filesystem::getRoot() && ! Cache\Scanner::isIgnoredFile($path) ) {
+ if (Filesystem::$loaded and $this->fakeRoot == Filesystem::getRoot() && !Cache\Scanner::isIgnoredFile($path)) {
foreach ($hooks as $hook) {
if ($hook != 'read') {
\OC_Hook::emit(
@@ -931,11 +939,11 @@ class View {
}
/**
- * Get the owner for a file or folder
- *
- * @param string $path
- * @return string
- */
+ * Get the owner for a file or folder
+ *
+ * @param string $path
+ * @return string
+ */
public function getOwner($path) {
return $this->basicOperation('getOwner', $path);
}