diff options
author | Morris Jobke <hey@morrisjobke.de> | 2019-02-26 00:17:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-26 00:17:25 +0100 |
commit | dc2798460b30fdf47e6141bcd775787f5a3a052b (patch) | |
tree | 2a491f032210a17f50d8cab43a536913e5eddd16 /lib | |
parent | 58fd78951c944d69770f2979387d865f1e7f91a5 (diff) | |
parent | b14700c9360b2589d35b20b00bc5b863d7fb8243 (diff) | |
download | nextcloud-server-dc2798460b30fdf47e6141bcd775787f5a3a052b.tar.gz nextcloud-server-dc2798460b30fdf47e6141bcd775787f5a3a052b.zip |
Merge pull request #14198 from nextcloud/bugfix/8647-exclude-file-name-patterns
Exclude file name patterns; ignore gentoo webapp files
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php b/lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php index e0ad6a550e5..26f4a56d15a 100644 --- a/lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php +++ b/lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php @@ -26,7 +26,7 @@ namespace OC\IntegrityCheck\Iterator; /** * Class ExcludeFileByNameFilterIterator provides a custom iterator which excludes - * entries with the specified file name from the file list. + * entries with the specified file name from the file list. These file names are matched exactly. * * @package OC\Integritycheck\Iterator */ @@ -42,21 +42,42 @@ class ExcludeFileByNameFilterIterator extends \RecursiveFilterIterator { '.DS_Store', // Mac OS X 'Thumbs.db', // Microsoft Windows '.directory', // Dolphin (KDE) - '.webapp', // Gentoo/Funtoo & derivatives use a tool known as webapp-config to manager wep-apps. + '.webapp', // Gentoo/Funtoo & derivatives use a tool known as webapp-config to manage web-apps. ]; /** + * Array of excluded file name parts. Those are not scanned by the integrity checker. + * These strings are regular expressions and any file names + * matching these expressions are ignored. + * + * @var array + */ + private $excludedFilenamePatterns = [ + '/^\.webapp-nextcloud-(\d+\.){2}(\d+)(-r\d+)?$/', // Gentoo/Funtoo & derivatives use a tool known as webapp-config to manage wep-apps. + ]; + + /** * @return bool */ public function accept() { - if($this->isDir()) { + /** @var \SplFileInfo $current */ + $current = $this->current(); + + if ($current->isDir()) { return true; } - return !\in_array( - $this->current()->getFilename(), - $this->excludedFilenames, - true - ); + $currentFileName = $current->getFilename(); + if (in_array($currentFileName, $this->excludedFilenames, true)){ + return false; + } + + foreach ($this->excludedFilenamePatterns as $pattern){ + if (preg_match($pattern, $currentFileName) > 0){ + return false; + } + } + + return true; } } |