From 043686814c67ba0e9214562e3fb13fd6a68c25d2 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Sat, 29 Sep 2018 23:52:22 +0200 Subject: [PATCH] Further fix to the search of customcode placeholders accross the system. --- README.md | 2 +- admin/README.txt | 2 +- admin/models/ajax.php | 83 ++++++++++++++++++++++++------ admin/models/joomla_components.php | 83 ++++++++++++++++++++++++------ 4 files changed, 134 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 56b14d5aa..1e5302dab 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo + *Version*: 2.9.6 + *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **195705** ++ *Line count*: **195803** + *Field count*: **1087** + *File count*: **1278** + *Folder count*: **201** diff --git a/admin/README.txt b/admin/README.txt index 56b14d5aa..1e5302dab 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -129,7 +129,7 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo + *Version*: 2.9.6 + *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **195705** ++ *Line count*: **195803** + *Field count*: **1087** + *File count*: **1278** + *Folder count*: **201** diff --git a/admin/models/ajax.php b/admin/models/ajax.php index e53bd52f8..6a7a009b2 100644 --- a/admin/models/ajax.php +++ b/admin/models/ajax.php @@ -2075,23 +2075,8 @@ class ComponentbuilderModelAjax extends JModelList if (isset($target['base64_search']) && isset($target['base64_search'][$key]) && isset($target['base64_search'][$key]['start']) && strpos($value, $target['base64_search'][$key]['start']) !== false) { - // first get the start property (if dynamic) - if (isset($target['base64_search'][$key]['_start'])) - { - $_start_property = $target['base64_search'][$key]['start']; - $_start_property .= ComponentbuilderHelper::getBetween($value, $target['base64_search'][$key]['start'], $target['base64_search'][$key]['_start']); - $_start_property .= $target['base64_search'][$key]['_start']; - } - else - { - $_start_property = $target['base64_search'][$key]['start']; - } - // get the base64 string - $_base64 = ComponentbuilderHelper::getBetween($value, $_start_property, $target['base64_search'][$key]['end']); - // now open the base64 text - $_tmp = ComponentbuilderHelper::openValidBase64($_base64); - // insert it back into the value (so we still search the whole string) - $value = str_replace($_base64, $_tmp, $value); + // search and open the base64 strings + $this->searchOpenBase64($value, $target['base64_search'][$key]); } // check if place holder set if (strpos($value, '[CUSTOMC' . 'ODE=' . (string) $functioName . ']') !== false || strpos($value, '[CUSTOMC' . 'ODE=' . (int) $id . ']') !== false || @@ -2125,6 +2110,70 @@ class ComponentbuilderModelAjax extends JModelList return false; } + /** + * Search for base64 strings and decode them + * + * @param string $value The string to search + * @param array $target The target search values + * + * @return void + * + */ + protected function searchOpenBase64(&$value, &$target) + { + // first get the start property (if dynamic) + $starts = array(); + if (isset($target['_start'])) + { + // get all values + $allBetween = ComponentbuilderHelper::getAllBetween($value, $target['start'], $target['_start']); + // just again make sure we found some + if (ComponentbuilderHelper::checkArray($allBetween)) + { + if (count((array) $allBetween) > 1) + { + // search for many + foreach ($allBetween as $between) + { + // load the starting property + $start = $target['start']; + $start .= $between; + $start .= $target['_start']; + + $starts[] = $start; + } + } + else + { + // load the starting property + $start = $target['start']; + $start .= array_values($allBetween)[0]; + $start .= $target['_start']; + + $starts[] = $start; + } + } + } + else + { + $starts[] = $target['start']; + } + // has any been found + if (ComponentbuilderHelper::checkArray($starts)) + { + foreach ($starts as $_start) + { + // get the base64 string + $base64 = ComponentbuilderHelper::getBetween($value, $_start, $target['end']); + // now open the base64 text + $tmp = ComponentbuilderHelper::openValidBase64($base64); + // insert it back into the value (so we still search the whole string) + $value = str_replace($base64, $tmp, $value); + } + } + } + + /** * The code search keys/targets * diff --git a/admin/models/joomla_components.php b/admin/models/joomla_components.php index b554fe9e7..248622965 100644 --- a/admin/models/joomla_components.php +++ b/admin/models/joomla_components.php @@ -1397,23 +1397,8 @@ class ComponentbuilderModelJoomla_components extends JModelList if (isset($target['base64_search']) && isset($target['base64_search'][$key]) && isset($target['base64_search'][$key]['start']) && strpos($value, $target['base64_search'][$key]['start']) !== false) { - // first get the start property (if dynamic) - if (isset($target['base64_search'][$key]['_start'])) - { - $_start_property = $target['base64_search'][$key]['start']; - $_start_property .= ComponentbuilderHelper::getBetween($value, $target['base64_search'][$key]['start'], $target['base64_search'][$key]['_start']); - $_start_property .= $target['base64_search'][$key]['_start']; - } - else - { - $_start_property = $target['base64_search'][$key]['start']; - } - // get the base64 string - $_base64 = ComponentbuilderHelper::getBetween($value, $_start_property, $target['base64_search'][$key]['end']); - // now open the base64 text - $_tmp = ComponentbuilderHelper::openValidBase64($_base64); - // insert it back into the value (so we still search the whole string) - $value = str_replace($_base64, $_tmp, $value); + // search and open the base64 strings + $this->searchOpenBase64($value, $target['base64_search'][$key]); } // search the value to see if it has custom code $codeArray = ComponentbuilderHelper::getAllBetween($value, '[CUSTOMC' . 'ODE=',']'); @@ -1572,6 +1557,70 @@ class ComponentbuilderModelJoomla_components extends JModelList return str_replace(array_keys(ComponentbuilderHelper::$constantPaths), array_values(ComponentbuilderHelper::$constantPaths), $path); } + /** + * Search for base64 strings and decode them + * + * @param string $value The string to search + * @param array $target The target search values + * + * @return void + * + */ + protected function searchOpenBase64(&$value, &$target) + { + // first get the start property (if dynamic) + $starts = array(); + if (isset($target['_start'])) + { + // get all values + $allBetween = ComponentbuilderHelper::getAllBetween($value, $target['start'], $target['_start']); + // just again make sure we found some + if (ComponentbuilderHelper::checkArray($allBetween)) + { + if (count((array) $allBetween) > 1) + { + // search for many + foreach ($allBetween as $between) + { + // load the starting property + $start = $target['start']; + $start .= $between; + $start .= $target['_start']; + + $starts[] = $start; + } + } + else + { + // load the starting property + $start = $target['start']; + $start .= array_values($allBetween)[0]; + $start .= $target['_start']; + + $starts[] = $start; + } + } + } + else + { + $starts[] = $target['start']; + } + // has any been found + if (ComponentbuilderHelper::checkArray($starts)) + { + foreach ($starts as $_start) + { + // get the base64 string + $base64 = ComponentbuilderHelper::getBetween($value, $_start, $target['end']); + // now open the base64 text + $tmp = ComponentbuilderHelper::openValidBase64($base64); + // insert it back into the value (so we still search the whole string) + $value = str_replace($base64, $tmp, $value); + } + } + } + + /** * The code search keys/targets *