From 7220686ef8d48d0a1e8f5d701cb0c871791600a9 Mon Sep 17 00:00:00 2001 From: Vladimir Reznichenko Date: Fri, 27 Apr 2018 21:21:36 +0200 Subject: [PATCH] SCA with Php Inspections (EA Ultimate): reverts as per code review --- src/Console/ConsoleIo.php | 6 ++++-- src/Core/Plugin.php | 3 ++- src/Event/EventManager.php | 3 ++- src/Utility/Hash.php | 3 ++- src/View/Helper/HtmlHelper.php | 3 ++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Console/ConsoleIo.php b/src/Console/ConsoleIo.php index 10a1679d683..65c5eabe34c 100644 --- a/src/Console/ConsoleIo.php +++ b/src/Console/ConsoleIo.php @@ -455,8 +455,9 @@ protected function _getInput($prompt, $options, $default) $defaultText = "[$default] "; } $this->_out->write('' . $prompt . "$optionsText\n$defaultText> ", 0); + $result = $this->_in->read(); - $result = trim($this->_in->read()); + $result = trim($result); if ($default !== null && ($result === '' || $result === null)) { return $default; } @@ -550,7 +551,8 @@ public function createFile($path, $contents, $forceOverwrite = false) if (file_exists($path) && $forceOverwrite === false) { $this->warning("File `{$path}` exists"); - $key = strtolower($this->askChoice('Do you want to overwrite?', ['y', 'n', 'a', 'q'], 'n')); + $key = $this->askChoice('Do you want to overwrite?', ['y', 'n', 'a', 'q'], 'n'); + $key = strtolower($key); if ($key === 'q') { $this->error('Quitting.', 2); diff --git a/src/Core/Plugin.php b/src/Core/Plugin.php index c082535bc8f..e76fc40cc70 100644 --- a/src/Core/Plugin.php +++ b/src/Core/Plugin.php @@ -241,7 +241,8 @@ public static function loadAll(array $options = []) } } if (Configure::check('plugins')) { - $plugins = array_unique(array_merge($plugins, array_keys(Configure::read('plugins')))); + $plugins = array_merge($plugins, array_keys(Configure::read('plugins'))); + $plugins = array_unique($plugins); } $collection = static::getCollection(); diff --git a/src/Event/EventManager.php b/src/Event/EventManager.php index 276eac84967..2e5cd7d181e 100644 --- a/src/Event/EventManager.php +++ b/src/Event/EventManager.php @@ -366,7 +366,8 @@ public function listeners($eventKey) $globalListeners = static::instance()->prioritisedListeners($eventKey); $globalListeners = empty($globalListeners) ? [] : $globalListeners; - $priorities = array_unique(array_merge(array_keys($globalListeners), array_keys($localListeners))); + $priorities = array_merge(array_keys($globalListeners), array_keys($localListeners)); + $priorities = array_unique($priorities); asort($priorities); $result = []; diff --git a/src/Utility/Hash.php b/src/Utility/Hash.php index 20e63565d84..68dac36f33e 100644 --- a/src/Utility/Hash.php +++ b/src/Utility/Hash.php @@ -712,7 +712,8 @@ public static function expand(array $data, $separator = '.') { $result = []; foreach ($data as $flat => $value) { - $keys = array_reverse(explode($separator, $flat)); + $keys = explode($separator, $flat); + $keys = array_reverse($keys); $child = [ $keys[0] => $value ]; diff --git a/src/View/Helper/HtmlHelper.php b/src/View/Helper/HtmlHelper.php index 0669297b016..730b3040c56 100644 --- a/src/View/Helper/HtmlHelper.php +++ b/src/View/Helper/HtmlHelper.php @@ -355,7 +355,8 @@ public function link($title, $url = null, array $options = []) unset($options['fullBase']); } else { $url = $this->Url->build($title); - $title = h(urldecode(htmlspecialchars_decode($url, ENT_QUOTES))); + $title = htmlspecialchars_decode($url, ENT_QUOTES); + $title = h(urldecode($title)); $escapeTitle = false; }