Merge pull request #4512 from owncloud/readdir-strict-equals
use strict equals in readdir loops to prevent issues with '0' files
This commit is contained in:
commit
884c6b5a82
|
@ -183,7 +183,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
|
||||||
}
|
}
|
||||||
|
|
||||||
$dh = $this->opendir($path);
|
$dh = $this->opendir($path);
|
||||||
while ($file = readdir($dh)) {
|
while (($file = readdir($dh)) !== false) {
|
||||||
if ($file === '.' || $file === '..') {
|
if ($file === '.' || $file === '..') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -464,7 +464,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
|
||||||
}
|
}
|
||||||
|
|
||||||
$dh = $this->opendir($path1);
|
$dh = $this->opendir($path1);
|
||||||
while ($file = readdir($dh)) {
|
while (($file = readdir($dh)) !== false) {
|
||||||
if ($file === '.' || $file === '..') {
|
if ($file === '.' || $file === '..') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,7 +206,7 @@ class Google extends \OC\Files\Storage\Common {
|
||||||
public function rmdir($path) {
|
public function rmdir($path) {
|
||||||
if (trim($path, '/') === '') {
|
if (trim($path, '/') === '') {
|
||||||
$dir = $this->opendir($path);
|
$dir = $this->opendir($path);
|
||||||
while ($file = readdir($dir)) {
|
while (($file = readdir($dh)) !== false) {
|
||||||
if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
|
if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
|
||||||
if (!$this->unlink($path.'/'.$file)) {
|
if (!$this->unlink($path.'/'.$file)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -137,7 +137,7 @@ class iRODS extends \OC\Files\Storage\StreamWrapper{
|
||||||
private function collectionMTime($path) {
|
private function collectionMTime($path) {
|
||||||
$dh = $this->opendir($path);
|
$dh = $this->opendir($path);
|
||||||
$lastCTime = $this->filemtime($path);
|
$lastCTime = $this->filemtime($path);
|
||||||
while ($file = readdir($dh)) {
|
while (($file = readdir($dh)) !== false) {
|
||||||
if ($file != '.' and $file != '..') {
|
if ($file != '.' and $file != '..') {
|
||||||
$time = $this->filemtime($file);
|
$time = $this->filemtime($file);
|
||||||
if ($time > $lastCTime) {
|
if ($time > $lastCTime) {
|
||||||
|
|
|
@ -99,7 +99,7 @@ class SMB extends \OC\Files\Storage\StreamWrapper{
|
||||||
private function shareMTime() {
|
private function shareMTime() {
|
||||||
$dh=$this->opendir('');
|
$dh=$this->opendir('');
|
||||||
$lastCtime=0;
|
$lastCtime=0;
|
||||||
while($file=readdir($dh)) {
|
while (($file = readdir($dh)) !== false) {
|
||||||
if ($file!='.' and $file!='..') {
|
if ($file!='.' and $file!='..') {
|
||||||
$ctime=$this->filemtime($file);
|
$ctime=$this->filemtime($file);
|
||||||
if ($ctime>$lastCtime) {
|
if ($ctime>$lastCtime) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ if ($dir) {
|
||||||
$dirlisting = true;
|
$dirlisting = true;
|
||||||
$dirContent = $view->opendir($dir);
|
$dirContent = $view->opendir($dir);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while($entryName = readdir($dirContent)) {
|
while(($entryName = readdir($dirContent)) !== false) {
|
||||||
if (!\OC\Files\Filesystem::isIgnoredDir($entryName)) {
|
if (!\OC\Files\Filesystem::isIgnoredDir($entryName)) {
|
||||||
$pos = strpos($dir.'/', '/', 1);
|
$pos = strpos($dir.'/', '/', 1);
|
||||||
$tmp = substr($dir, 0, $pos);
|
$tmp = substr($dir, 0, $pos);
|
||||||
|
|
|
@ -666,7 +666,7 @@ class OC_App{
|
||||||
}
|
}
|
||||||
$dh = opendir( $apps_dir['path'] );
|
$dh = opendir( $apps_dir['path'] );
|
||||||
|
|
||||||
while( $file = readdir( $dh ) ) {
|
while (($file = readdir($dh)) !== false) {
|
||||||
|
|
||||||
if ($file[0] != '.' and is_file($apps_dir['path'].'/'.$file.'/appinfo/app.php')) {
|
if ($file[0] != '.' and is_file($apps_dir['path'].'/'.$file.'/appinfo/app.php')) {
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ abstract class OC_Archive{
|
||||||
function addRecursive($path, $source) {
|
function addRecursive($path, $source) {
|
||||||
if($dh=opendir($source)) {
|
if($dh=opendir($source)) {
|
||||||
$this->addFolder($path);
|
$this->addFolder($path);
|
||||||
while($file=readdir($dh)) {
|
while (($file = readdir($dh)) !== false) {
|
||||||
if($file=='.' or $file=='..') {
|
if($file=='.' or $file=='..') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ class OC_Cache_File{
|
||||||
$storage = $this->getStorage();
|
$storage = $this->getStorage();
|
||||||
if($storage and $storage->is_dir('/')) {
|
if($storage and $storage->is_dir('/')) {
|
||||||
$dh=$storage->opendir('/');
|
$dh=$storage->opendir('/');
|
||||||
while($file=readdir($dh)) {
|
while (($file = readdir($dh)) !== false) {
|
||||||
if($file!='.' and $file!='..' and ($prefix==='' || strpos($file, $prefix) === 0)) {
|
if($file!='.' and $file!='..' and ($prefix==='' || strpos($file, $prefix) === 0)) {
|
||||||
$storage->unlink('/'.$file);
|
$storage->unlink('/'.$file);
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ class OC_Cache_File{
|
||||||
if($storage and $storage->is_dir('/')) {
|
if($storage and $storage->is_dir('/')) {
|
||||||
$now = time();
|
$now = time();
|
||||||
$dh=$storage->opendir('/');
|
$dh=$storage->opendir('/');
|
||||||
while($file=readdir($dh)) {
|
while (($file = readdir($dh)) !== false) {
|
||||||
if($file!='.' and $file!='..') {
|
if($file!='.' and $file!='..') {
|
||||||
$mtime = $storage->filemtime('/'.$file);
|
$mtime = $storage->filemtime('/'.$file);
|
||||||
if ($mtime < $now) {
|
if ($mtime < $now) {
|
||||||
|
|
|
@ -69,7 +69,7 @@ class OC_Cache_FileGlobal{
|
||||||
$prefix = $this->fixKey($prefix);
|
$prefix = $this->fixKey($prefix);
|
||||||
if($cache_dir and is_dir($cache_dir)) {
|
if($cache_dir and is_dir($cache_dir)) {
|
||||||
$dh=opendir($cache_dir);
|
$dh=opendir($cache_dir);
|
||||||
while($file=readdir($dh)) {
|
while (($file = readdir($dh)) !== false) {
|
||||||
if($file!='.' and $file!='..' and ($prefix==='' || strpos($file, $prefix) === 0)) {
|
if($file!='.' and $file!='..' and ($prefix==='' || strpos($file, $prefix) === 0)) {
|
||||||
unlink($cache_dir.$file);
|
unlink($cache_dir.$file);
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ class OC_Cache_FileGlobal{
|
||||||
$cache_dir = self::getCacheDir();
|
$cache_dir = self::getCacheDir();
|
||||||
if($cache_dir and is_dir($cache_dir)) {
|
if($cache_dir and is_dir($cache_dir)) {
|
||||||
$dh=opendir($cache_dir);
|
$dh=opendir($cache_dir);
|
||||||
while($file=readdir($dh)) {
|
while (($file = readdir($dh)) !== false) {
|
||||||
if($file!='.' and $file!='..') {
|
if($file!='.' and $file!='..') {
|
||||||
$mtime = filemtime($cache_dir.$file);
|
$mtime = filemtime($cache_dir.$file);
|
||||||
if ($mtime < $now) {
|
if ($mtime < $now) {
|
||||||
|
|
|
@ -88,7 +88,7 @@ class ObjectTree extends \Sabre_DAV_ObjectTree {
|
||||||
} else {
|
} else {
|
||||||
Filesystem::mkdir($destination);
|
Filesystem::mkdir($destination);
|
||||||
$dh = Filesystem::opendir($source);
|
$dh = Filesystem::opendir($source);
|
||||||
while ($subnode = readdir($dh)) {
|
while (($subnode = readdir($dh)) !== false) {
|
||||||
|
|
||||||
if ($subnode == '.' || $subnode == '..') continue;
|
if ($subnode == '.' || $subnode == '..') continue;
|
||||||
$this->copy($source . '/' . $subnode, $destination . '/' . $subnode);
|
$this->copy($source . '/' . $subnode, $destination . '/' . $subnode);
|
||||||
|
|
|
@ -159,7 +159,7 @@ class Scanner extends BasicEmitter {
|
||||||
$newChildren = array();
|
$newChildren = array();
|
||||||
if ($this->storage->is_dir($path) && ($dh = $this->storage->opendir($path))) {
|
if ($this->storage->is_dir($path) && ($dh = $this->storage->opendir($path))) {
|
||||||
\OC_DB::beginTransaction();
|
\OC_DB::beginTransaction();
|
||||||
while ($file = readdir($dh)) {
|
while (($file = readdir($dh)) !== false) {
|
||||||
$child = ($path) ? $path . '/' . $file : $file;
|
$child = ($path) ? $path . '/' . $file : $file;
|
||||||
if (!Filesystem::isIgnoredDir($file)) {
|
if (!Filesystem::isIgnoredDir($file)) {
|
||||||
$newChildren[] = $file;
|
$newChildren[] = $file;
|
||||||
|
|
|
@ -142,7 +142,7 @@ abstract class Common implements \OC\Files\Storage\Storage {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
$directoryHandle = $this->opendir($directory);
|
$directoryHandle = $this->opendir($directory);
|
||||||
while ($contents = readdir($directoryHandle)) {
|
while (($contents = readdir($directoryHandle)) !== false) {
|
||||||
if (!\OC\Files\Filesystem::isIgnoredDir($contents)) {
|
if (!\OC\Files\Filesystem::isIgnoredDir($contents)) {
|
||||||
$path = $directory . '/' . $contents;
|
$path = $directory . '/' . $contents;
|
||||||
if ($this->is_dir($path)) {
|
if ($this->is_dir($path)) {
|
||||||
|
@ -225,7 +225,7 @@ abstract class Common implements \OC\Files\Storage\Storage {
|
||||||
|
|
||||||
private function addLocalFolder($path, $target) {
|
private function addLocalFolder($path, $target) {
|
||||||
if ($dh = $this->opendir($path)) {
|
if ($dh = $this->opendir($path)) {
|
||||||
while ($file = readdir($dh)) {
|
while (($file = readdir($dh)) !== false) {
|
||||||
if ($file !== '.' and $file !== '..') {
|
if ($file !== '.' and $file !== '..') {
|
||||||
if ($this->is_dir($path . '/' . $file)) {
|
if ($this->is_dir($path . '/' . $file)) {
|
||||||
mkdir($target . '/' . $file);
|
mkdir($target . '/' . $file);
|
||||||
|
@ -243,7 +243,7 @@ abstract class Common implements \OC\Files\Storage\Storage {
|
||||||
$files = array();
|
$files = array();
|
||||||
$dh = $this->opendir($dir);
|
$dh = $this->opendir($dir);
|
||||||
if ($dh) {
|
if ($dh) {
|
||||||
while ($item = readdir($dh)) {
|
while (($item = readdir($dh)) !== false) {
|
||||||
if ($item == '.' || $item == '..') continue;
|
if ($item == '.' || $item == '..') continue;
|
||||||
if (strstr(strtolower($item), strtolower($query)) !== false) {
|
if (strstr(strtolower($item), strtolower($query)) !== false) {
|
||||||
$files[] = $dir . '/' . $item;
|
$files[] = $dir . '/' . $item;
|
||||||
|
|
|
@ -499,7 +499,7 @@ class View {
|
||||||
} else {
|
} else {
|
||||||
if ($this->is_dir($path1) && ($dh = $this->opendir($path1))) {
|
if ($this->is_dir($path1) && ($dh = $this->opendir($path1))) {
|
||||||
$result = $this->mkdir($path2);
|
$result = $this->mkdir($path2);
|
||||||
while ($file = readdir($dh)) {
|
while (($file = readdir($dh)) !== false) {
|
||||||
if (!Filesystem::isIgnoredDir($file)) {
|
if (!Filesystem::isIgnoredDir($file)) {
|
||||||
$result = $this->copy($path1 . '/' . $file, $path2 . '/' . $file);
|
$result = $this->copy($path1 . '/' . $file, $path2 . '/' . $file);
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ class OC_Installer{
|
||||||
if(!is_file($extractDir.'/appinfo/info.xml')) {
|
if(!is_file($extractDir.'/appinfo/info.xml')) {
|
||||||
//try to find it in a subdir
|
//try to find it in a subdir
|
||||||
$dh=opendir($extractDir);
|
$dh=opendir($extractDir);
|
||||||
while($folder=readdir($dh)) {
|
while (($folder = readdir($dh)) !== false) {
|
||||||
if($folder[0]!='.' and is_dir($extractDir.'/'.$folder)) {
|
if($folder[0]!='.' and is_dir($extractDir.'/'.$folder)) {
|
||||||
if(is_file($extractDir.'/'.$folder.'/appinfo/info.xml')) {
|
if(is_file($extractDir.'/'.$folder.'/appinfo/info.xml')) {
|
||||||
$extractDir.='/'.$folder;
|
$extractDir.='/'.$folder;
|
||||||
|
|
Loading…
Reference in New Issue