From 99b7d66cf2b00a29edbb13ab1022c7ccc1fcc865 Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Fri, 3 Feb 2023 11:09:43 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B05944=20-=20Wrong=20filter=20for=20utils:?= =?UTF-8?q?:GetClassesForInterface()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/utils.inc.php | 18 ++++++++++++------ pages/preferences.php | 2 +- .../TwigBase/UI/UIBlockExtension.php | 6 ++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/application/utils.inc.php b/application/utils.inc.php index 3afd936ed..439b565f3 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -2745,12 +2745,18 @@ HTML; $bSkipped = true; } else { - foreach ($aExcludedPath as $sExcludedPath) { - // Note: We use '#' as delimiters as usual '/' is often used in paths. - if ($sExcludedPath !== '' && preg_match('#'.$sExcludedPath.'#', $sPHPFile) === 1) { - $bSkipped = true; - break; + $sPHPFile = self::LocalPath($sPHPFile); + if ($sPHPFile !== false) { + $sPHPFile = '/'.$sPHPFile; // for regex + foreach ($aExcludedPath as $sExcludedPath) { + // Note: We use '#' as delimiters as usual '/' is often used in paths. + if ($sExcludedPath !== '' && preg_match('#'.$sExcludedPath.'#', $sPHPFile) === 1) { + $bSkipped = true; + break; + } } + } else { + $bSkipped = true; // file not found } } @@ -2788,7 +2794,7 @@ HTML; $aResultPref = []; $aShortcutPrefs = appUserPreferences::GetPref('keyboard_shortcuts', []); // Note: Mind the 4 blackslashes, see utils::GetClassesForInterface() - $aShortcutClasses = utils::GetClassesForInterface('iKeyboardShortcut', '', array('[\\\\/]lib[\\\\/]', '[\\\\/]node_modules[\\\\/]', '[\\\\/]test[\\\\/]')); + $aShortcutClasses = utils::GetClassesForInterface('iKeyboardShortcut', '', array('[\\\\/]lib[\\\\/]', '[\\\\/]node_modules[\\\\/]', '[\\\\/]test[\\\\/]', '[\\\\/]tests[\\\\/]')); foreach ($aShortcutClasses as $cShortcutPlugin) { $sTriggeredElement = $cShortcutPlugin::GetShortcutTriggeredElementSelector(); diff --git a/pages/preferences.php b/pages/preferences.php index b21b8fac1..adf2929c3 100644 --- a/pages/preferences.php +++ b/pages/preferences.php @@ -774,7 +774,7 @@ try { break; case 'apply_keyboard_shortcuts': // Note: Mind the 4 blackslashes, see utils::GetClassesForInterface() - $aShortcutClasses = utils::GetClassesForInterface('iKeyboardShortcut', '', array('[\\\\/]lib[\\\\/]', '[\\\\/]node_modules[\\\\/]', '[\\\\/]test[\\\\/]')); + $aShortcutClasses = utils::GetClassesForInterface('iKeyboardShortcut', '', array('[\\\\/]lib[\\\\/]', '[\\\\/]node_modules[\\\\/]', '[\\\\/]test[\\\\/]', '[\\\\/]tests[\\\\/]')); $aShortcutPrefs = []; foreach ($aShortcutClasses as $cShortcutPlugin) { foreach ($cShortcutPlugin::GetShortcutKeys() as $aShortcutKey) { diff --git a/sources/application/TwigBase/UI/UIBlockExtension.php b/sources/application/TwigBase/UI/UIBlockExtension.php index 9af1c1d4d..3a81a647b 100644 --- a/sources/application/TwigBase/UI/UIBlockExtension.php +++ b/sources/application/TwigBase/UI/UIBlockExtension.php @@ -8,9 +8,7 @@ namespace Combodo\iTop\Application\TwigBase\UI; -use Exception; -use ReflectionClass; -use SetupUtils; +use Combodo\iTop\Application\UI\Base\iUIBlockFactory; use Twig\Extension\AbstractExtension; use utils; @@ -30,7 +28,7 @@ class UIBlockExtension extends AbstractExtension { $aParsers = []; - $sInterface = "Combodo\\iTop\\Application\\UI\\Base\\iUIBlockFactory"; + $sInterface = iUIBlockFactory::class; $aFactoryClasses = utils::GetClassesForInterface($sInterface, 'UIBlockFactory'); foreach ($aFactoryClasses as $sFactoryClass) {