Further fix to the search of customcode placeholders accross the system.

This commit is contained in:
Llewellyn van der Merwe 2018-09-29 23:52:22 +02:00
parent fdd1cf7390
commit 043686814c
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
4 changed files with 134 additions and 36 deletions

View File

@ -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**

View File

@ -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**

View File

@ -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
*

View File

@ -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
*