Commit af01d9aa authored by Rémy DANIEL's avatar Rémy DANIEL

[FEATURE] Enable extension key whitelist

Resolves: #22
parent c45703c9
......@@ -103,6 +103,9 @@ class ConfigurationService extends AbstractService {
if (!\preg_match('/^\/.*\/.*$/', $this->extConfig['extIgnore'])) {
$this->extConfig['extIgnore'] = '/^csh_.*$/';
}
if (!\preg_match('/^\/.*\/.*$/', $this->extConfig['extWhitelist'])) {
$this->extConfig['extWhitelist'] = '';
}
$this->extConfig['execBackup'] = TRUE;
$this->extConfig['viewSysExt'] = TRUE;
......@@ -234,8 +237,10 @@ class ConfigurationService extends AbstractService {
if ($this->extConfig['viewLocalExt']) {
if (\count(
$content = Functions::searchExtensions(
$pathSite . Typo3Lib::PATH_LOCAL_EXT, $this->extConfig['viewStateExt'],
$this->extConfig['extIgnore']
$pathSite . Typo3Lib::PATH_LOCAL_EXT,
$this->extConfig['viewStateExt'],
$this->extConfig['extIgnore'],
$this->extConfig['extWhitelist']
)
)
) {
......@@ -247,8 +252,10 @@ class ConfigurationService extends AbstractService {
if ($this->extConfig['viewGlobalExt'] && \is_dir(Typo3Lib::PATH_GLOBAL_EXT)) {
if (\count(
$content = Functions::searchExtensions(
$pathSite . Typo3Lib::PATH_GLOBAL_EXT, $this->extConfig['viewStateExt'],
$this->extConfig['extIgnore']
$pathSite . Typo3Lib::PATH_GLOBAL_EXT,
$this->extConfig['viewStateExt'],
$this->extConfig['extIgnore'],
$this->extConfig['extWhitelist']
)
)
) {
......@@ -260,8 +267,10 @@ class ConfigurationService extends AbstractService {
if ($this->extConfig['viewSysExt']) {
if (\count(
$content = Functions::searchExtensions(
$pathSite . Typo3Lib::PATH_SYS_EXT, $this->extConfig['viewStateExt'],
$this->extConfig['extIgnore']
$pathSite . Typo3Lib::PATH_SYS_EXT,
$this->extConfig['viewStateExt'],
$this->extConfig['extIgnore'],
$this->extConfig['extWhitelist']
)
)
) {
......
......@@ -82,13 +82,15 @@ class Functions {
* @param string $path path
* @param integer $state optional: extension state to ignore (see above)
* @param string $extIgnoreRegExp optional: directories to ignore (regular expression; pcre with slashes)
* @param string $extWhitelistRegExp optional: keep only those directories (regular expression; pcre with slashes)
* @return array result of the search
*/
public static function searchExtensions($path, $state = 0, $extIgnoreRegExp = '') {
public static function searchExtensions($path, $state = 0, $extIgnoreRegExp = '', $extWhitelistRegExp = '') {
if (!@$fhd = opendir($path)) {
throw new Exception('cant open "' . $path . '"');
}
$path = rtrim($path, '/');
$extArray = array();
while ($extDir = readdir($fhd)) {
$extDirPath = $path . '/' . $extDir;
......@@ -103,6 +105,11 @@ class Functions {
continue;
}
// check, if the directory/extension should be saved
if ($extWhitelistRegExp !== '' && !preg_match($extWhitelistRegExp, $extDir)) {
continue;
}
// state filter
if ($state) {
$extState = (int) ExtensionManagementUtility::isLoaded($extDir);
......
......@@ -17,6 +17,7 @@ defaultLanguage If 'en' is not default language in TYPO3 BE,
default language must be defined here (e.g. de). If this field is empty,
English is used as default.
extIgnore Regular expression which limits the extension key list. /^(CVS|.svn|.git|csh_)/
extWhitelist Regular expression which restricts the extension key list. -
changeXlfDate If set to TRUE, LFEditor will change the date in XLF files on each change. 1
================ ========================================================================== ============================
......
......@@ -12,6 +12,9 @@ searchRegex = /^([a-z0-9_]*locallang[a-z0-9_-]*\.(php|xml)|[^\.]*\.xlf)$/i
# cat=basic; type=string; label=Ignore extensions: Regular expression which limits the extension key list. An example for blacklist specific extensions, from the extension select box, would be the following pattern: /^(gridelements|lfeditor|CVS|.svn|.git|csh_)/
extIgnore = /^(CVS|.svn|.git|csh_)/
# cat=basic; type=string; label=Only extensions: Regular expression which restricts the extension key list. An example for list only specific extensions in the extension select box, would be the following pattern: /^(felogin|lfeditor)/. extIgnore is evaluated before extWhitelist.
extWhitelist =
# cat=basic; type=boolean; label=Change XLF date: If set to TRUE, LFEditor will change the date in XLF files on each change.
changeXlfDate = 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment