mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-20 07:42:17 +02:00
N°4867 - "Twig content not allowed" error when use the extkey widget search icon in the user portal - Remove useless code
This commit is contained in:
@@ -114,9 +114,8 @@ class ObjectFormManager extends FormManager
|
|||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
* @throws \SecurityException if twig content is present and $bTrustContent is false
|
* @throws \SecurityException if twig content is present and $bTrustContent is false
|
||||||
*
|
*
|
||||||
* @since 2.7.6 3.0.0 N°4384 new $bTrustContent parameter
|
|
||||||
*/
|
*/
|
||||||
public static function FromJSON($sJson, $bTrustContent = false)
|
public static function FromJSON($sJson)
|
||||||
{
|
{
|
||||||
$aJson = static::DecodeFormManagerData($sJson);
|
$aJson = static::DecodeFormManagerData($sJson);
|
||||||
|
|
||||||
@@ -172,37 +171,6 @@ class ObjectFormManager extends FormManager
|
|||||||
return $oFormManager;
|
return $oFormManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $sPostedFormManagerData received data from the browser
|
|
||||||
* @param array $aOriginalFormProperties data generated server side
|
|
||||||
*
|
|
||||||
* @return bool true if the data are identical
|
|
||||||
*
|
|
||||||
* @since 2.7.6 3.0.0 N°4384 Check formmanager_data
|
|
||||||
*/
|
|
||||||
public static function CanTrustFormLayoutContent($sPostedFormManagerData, $aOriginalFormProperties)
|
|
||||||
{
|
|
||||||
$aPostedFormManagerData = static::DecodeFormManagerData($sPostedFormManagerData);
|
|
||||||
$sPostedFormLayoutType = (isset($aPostedFormManagerData['formproperties']['layout']['type'])) ? $aPostedFormManagerData['formproperties']['layout']['type'] : '';
|
|
||||||
|
|
||||||
if ($sPostedFormLayoutType === 'xhtml') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We need to parse the content so that autoclose tags are returned correctly (`<div />` => `<div></div>`)
|
|
||||||
$oHtmlDocument = new \DOMDocument();
|
|
||||||
|
|
||||||
$sPostedFormLayoutContent = (isset($aPostedFormManagerData['formproperties']['layout']['content'])) ? $aPostedFormManagerData['formproperties']['layout']['content'] : '';
|
|
||||||
$oHtmlDocument->loadXML('<root>'.$sPostedFormLayoutContent.'</root>');
|
|
||||||
$sPostedFormLayoutRendered = $oHtmlDocument->saveHTML();
|
|
||||||
|
|
||||||
$sOriginalFormLayoutContent = (isset($aOriginalFormProperties['layout']['content'])) ? $aOriginalFormProperties['layout']['content'] : '';
|
|
||||||
$oHtmlDocument->loadXML('<root>'.$sOriginalFormLayoutContent.'</root>');
|
|
||||||
$sOriginalFormLayoutContentRendered = $oHtmlDocument->saveHTML();
|
|
||||||
|
|
||||||
return ($sPostedFormLayoutRendered === $sOriginalFormLayoutContentRendered);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\DependencyInjection\ContainerInterface
|
* @return \Symfony\Component\DependencyInjection\ContainerInterface
|
||||||
|
|||||||
@@ -132,12 +132,10 @@ class ObjectFormHandlerHelper
|
|||||||
$bModal = ($oRequest->isXmlHttpRequest() && empty($sOperation));
|
$bModal = ($oRequest->isXmlHttpRequest() && empty($sOperation));
|
||||||
|
|
||||||
// - Retrieve form properties
|
// - Retrieve form properties
|
||||||
$aOriginalFormProperties = ApplicationHelper::GetLoadedFormFromClass($this->aCombodoPortalInstanceConf['forms'], $sObjectClass, $sMode);
|
|
||||||
if ($aFormProperties === null)
|
if ($aFormProperties === null)
|
||||||
{
|
{
|
||||||
$aFormProperties = $aOriginalFormProperties;
|
$aFormProperties = ApplicationHelper::GetLoadedFormFromClass($this->aCombodoPortalInstanceConf['forms'], $sObjectClass, $sMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - Create and
|
// - Create and
|
||||||
if (empty($sOperation))
|
if (empty($sOperation))
|
||||||
{
|
{
|
||||||
@@ -299,8 +297,7 @@ class ObjectFormHandlerHelper
|
|||||||
throw new HttpException(Response::HTTP_INTERNAL_SERVER_ERROR, 'Parameters formmanager_class and formmanager_data must be defined.');
|
throw new HttpException(Response::HTTP_INTERNAL_SERVER_ERROR, 'Parameters formmanager_class and formmanager_data must be defined.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$bTrustContent = $sFormManagerClass::CanTrustFormLayoutContent($sFormManagerData, $aOriginalFormProperties);
|
$oFormManager = $sFormManagerClass::FromJSON($sFormManagerData);
|
||||||
$oFormManager = $sFormManagerClass::FromJSON($sFormManagerData, $bTrustContent);
|
|
||||||
$oFormManager->SetContainer($this->oContainer);
|
$oFormManager->SetContainer($this->oContainer);
|
||||||
|
|
||||||
// Applying action rules if present
|
// Applying action rules if present
|
||||||
|
|||||||
@@ -99,7 +99,8 @@ class AppExtension extends AbstractExtension
|
|||||||
|
|
||||||
return $sUrl;
|
return $sUrl;
|
||||||
});
|
});
|
||||||
//$filters[] = new TwigFilter('filter', 'twig_array_filter');
|
//since 2.7.7 3.0.2 3.1.0 N°4867 "Twig content not allowed" error when use the extkey widget search icon in the user portal
|
||||||
|
//overwrite native twig filter : disable use of 'system' filter
|
||||||
$filters[] = new Twig_SimpleFilter('filter', function ($array, $arrow) {
|
$filters[] = new Twig_SimpleFilter('filter', function ($array, $arrow) {
|
||||||
if ($arrow == 'system'){
|
if ($arrow == 'system'){
|
||||||
return json_encode($array);
|
return json_encode($array);
|
||||||
|
|||||||
@@ -1733,7 +1733,6 @@
|
|||||||
<module_parameters>
|
<module_parameters>
|
||||||
<parameters id="itop-portal" _delta="define">
|
<parameters id="itop-portal" _delta="define">
|
||||||
<lazy_loading_threshold>500</lazy_loading_threshold><!-- Will be placed in the conf/<env>/config-itop.php file under the itop-portal module's settings -->
|
<lazy_loading_threshold>500</lazy_loading_threshold><!-- Will be placed in the conf/<env>/config-itop.php file under the itop-portal module's settings -->
|
||||||
<enable_formmanager_content_check type="boolean">true</enable_formmanager_content_check>
|
|
||||||
</parameters>
|
</parameters>
|
||||||
</module_parameters>
|
</module_parameters>
|
||||||
</itop_design>
|
</itop_design>
|
||||||
|
|||||||
Reference in New Issue
Block a user