From 631444bdb5733e961177b6463a179ce00df0f8e5 Mon Sep 17 00:00:00 2001
From: appu <apparao@vtiger.com>
Date: Mon, 11 Dec 2023 17:03:20 +0530
Subject: [PATCH] #157773041:Not able create new tags

---
 include/utils/VtlibUtils.php                  |  5 +--
 includes/http/Request.php                     | 32 +++++++----------
 .../modules/Settings/Vtiger/ModuleHeader.tpl  | 36 +++++++++----------
 layouts/v7/modules/Vtiger/ModuleHeader.tpl    |  8 ++---
 4 files changed, 37 insertions(+), 44 deletions(-)

diff --git a/include/utils/VtlibUtils.php b/include/utils/VtlibUtils.php
index 1215aea17..6cb7024e7 100644
--- a/include/utils/VtlibUtils.php
+++ b/include/utils/VtlibUtils.php
@@ -709,7 +709,7 @@ function vtlib_purify($input, $ignore = false) {
             if (is_array($input)) {
                 $value = array();
                 foreach ($input as $k => $v) {
-                    $value[$k] = vtlib_purify($v, $ignore);
+                    $value[$k] = str_replace('&amp;', '&', vtlib_purify($v, $ignore));
                 }
             } else { // Simple type
                 $value = $__htmlpurifier_instance->purify($input);
@@ -717,8 +717,9 @@ function vtlib_purify($input, $ignore = false) {
             }
         }
         $purified_cache[$md5OfInput] = $value;
+    } else {
+        $value = str_replace('&amp;', '&', $value);
     }
-    $value = str_replace('&amp;', '&', $value);
     return $value;
 }
 
diff --git a/includes/http/Request.php b/includes/http/Request.php
index c8282f751..cdaabcd91 100644
--- a/includes/http/Request.php
+++ b/includes/http/Request.php
@@ -8,28 +8,13 @@
  * All Rights Reserved.
  ************************************************************************************/
 
-class Vtiger_Request implements ArrayAccess {
+class Vtiger_Request {
 
 	// Datastore
 	private $valuemap;
 	private $rawvaluemap;
 	private $defaultmap = array();
 
-	// ArrayAccess Start
-	public function offsetExists($key) {
-		return $this->has($key);
-	}
-	public function offsetSet($key, $value) {
-		$this->set($key, $value);
-	}
-	public function offsetGet($key) {
-		return $this->get($key);
-	}
-	public function offsetUnset($key) {
-		// Ignore
-	}
-	// ArrayAccess End
-
 	/**
 	 * Default constructor
 	 */
@@ -72,10 +57,17 @@ class Vtiger_Request implements ArrayAccess {
 			}
 		}
 		if($isJSON) {
-			$decodeValue = json_decode($value, true);
-                        $value = json_last_error() ? $value : $decodeValue;
-		}
-
+//                    $decodeValue = json_decode($value, true);
+//                    $value = json_last_error() ? $value : $decodeValue;
+                    $oldValue = Zend_Json::$useBuiltinEncoderDecoder;
+		    Zend_Json::$useBuiltinEncoderDecoder = false;
+		    $decodeValue = Zend_Json::decode($value);
+		    if(isset($decodeValue)) {
+		            $value = $decodeValue;
+		    }
+		    Zend_Json::$useBuiltinEncoderDecoder  = $oldValue;
+                }
+                
         //Handled for null because vtlib_purify returns empty string
         if(!empty($value)){
             $value = vtlib_purify($value);
diff --git a/layouts/v7/modules/Settings/Vtiger/ModuleHeader.tpl b/layouts/v7/modules/Settings/Vtiger/ModuleHeader.tpl
index c55813585..7b66072dd 100644
--- a/layouts/v7/modules/Settings/Vtiger/ModuleHeader.tpl
+++ b/layouts/v7/modules/Settings/Vtiger/ModuleHeader.tpl
@@ -19,7 +19,7 @@
 					</a>
 					&nbsp;<span class="fa fa-angle-right pull-left {if $VIEW eq 'Index' && $MODULE eq 'Vtiger'} hide {/if}" aria-hidden="true" style="padding-top: 12px;padding-left: 5px; padding-right: 5px;"></span>
 				{/if}
-				{if $MODULE neq 'Vtiger' or $REQ.view neq 'Index'}
+				{if $MODULE neq 'Vtiger' or $REQ->get('view') neq 'Index'}
 					{if $ACTIVE_BLOCK['block']}
 						<span class="current-filter-name filter-name pull-left">
 							{vtranslate($ACTIVE_BLOCK['block'], $QUALIFIED_MODULE)}&nbsp;
@@ -35,13 +35,13 @@
 								{assign var=URL value=$MODULE_MODEL->getDefaultUrl()}
 							{/if}
 							{if $URL|strpos:'parent' eq ''}
-								{assign var=URL value=$URL|cat:'&parent='|cat:$REQ.parent}
+								{assign var=URL value=$URL|cat:'&parent='|cat:$REQ->get('parent')}
 							{/if}
 						{/if}
 						<span class="current-filter-name settingModuleName filter-name pull-left">
-							{if $REQ.view eq 'Calendar'}
-								{if $REQ.mode eq 'Edit'}
-									<a href="{"index.php?module="|cat:$REQ.module|cat:'&parent='|cat:$REQ.parent|cat:'&view='|cat:$REQ.view}">
+							{if $REQ->get('view') eq 'Calendar'}
+								{if $REQ->get('view') eq 'Edit'}
+									<a href="{"index.php?module="|cat:$REQ->get('module')|cat:'&parent='|cat:$REQ->get('parent')|cat:'&view='|cat:$REQ->get('view')}">
 										{vtranslate({$PAGETITLE}, $QUALIFIED_MODULE)}
 									</a>&nbsp;
                                                                         <a href="">
@@ -51,22 +51,22 @@
 								{else}
                                                                     <a href="">{vtranslate({$PAGETITLE}, $QUALIFIED_MODULE)}&nbsp;<span class="fa fa-angle-right" aria-hidden="true"></span>&nbsp;{$USER_MODEL->getName()}</a>
 								{/if}
-							{else if $REQ.view neq 'List' and $REQ.module eq 'Users'}
-								{if $REQ.view eq 'PreferenceEdit'}
-									<a href="{"index.php?module="|cat:$REQ.module|cat:'&parent='|cat:$REQ.parent|cat:'&view=PreferenceDetail&record='|cat:$REQ.record}">
+							{else if $REQ->get('view') neq 'List' and $REQ->get('module') eq 'Users'}
+								{if $REQ->get('view') eq 'PreferenceEdit'}
+									<a href="{"index.php?module="|cat:$REQ->get('module')|cat:'&parent='|cat:$REQ->get('parent')|cat:'&view=PreferenceDetail&record='|cat:$REQ->get('record')}">
 										{vtranslate($ACTIVE_BLOCK['block'], $QUALIFIED_MODULE)}&nbsp;
 									</a>
                                                                         <a href="">
                                                                             <span class="fa fa-angle-right" aria-hidden="true"></span>&nbsp;
                                                                             {vtranslate('LBL_EDITING', $MODULE)} :&nbsp;{$USER_MODEL->getName()}
                                                                         </a>
-								{else if $REQ.view eq 'Edit' or $REQ.view eq 'Detail'}
+								{else if $REQ->get('view') eq 'Edit' or $REQ->get('view') eq 'Detail'}
 									<a href="{$URL}">
-									{if $REQ.extensionModule}{$REQ.extensionModule}{else}{vtranslate({$PAGETITLE}, $QUALIFIED_MODULE)}{/if}&nbsp;
+									{if $REQ->get('extensionModule')}{$REQ->get('extensionModule')}{else}{vtranslate({$PAGETITLE}, $QUALIFIED_MODULE)}{/if}&nbsp;
 									</a>
                                                                         <a href="">
                                                                             <span class="fa fa-angle-right" aria-hidden="true"></span>&nbsp;
-                                                                            {if $REQ.view eq 'Edit'}
+                                                                            {if $REQ->get('view') eq 'Edit'}
                                                                                     {if $RECORD}
                                                                                             {vtranslate('LBL_EDITING', $MODULE)} :&nbsp;{$RECORD->getName()}
                                                                                     {else}
@@ -79,10 +79,10 @@
 								{else}
                                                                     <a href="">{$USER_MODEL->getName()}</a>
 								{/if}
-							{else if $URL and $URL|strpos:$REQ.view eq ''}
+							{else if $URL and $URL|strpos:$REQ->get('view') eq ''}
 								<a href="{$URL}">
-								{if $REQ.extensionModule}
-									{$REQ.extensionModule}
+								{if $REQ->get('extensionModule')}
+									{$REQ->get('extensionModule')}
 								{else}
 									{vtranslate({$PAGETITLE}, $QUALIFIED_MODULE)}
 								{/if}
@@ -90,20 +90,20 @@
                                                                 <a href="">
                                                                     <span class="fa fa-angle-right" aria-hidden="true"></span>&nbsp;
                                                                     {if $RECORD}
-                                                                            {if $REQ.view eq 'Edit'}
+                                                                            {if $REQ->get('view') eq 'Edit'}
                                                                                     {vtranslate('LBL_EDITING', $MODULE)} :&nbsp;
                                                                             {/if}
                                                                             {$RECORD->getName()}
                                                                     {/if}
                                                                 </a>
 							{else}
-								&nbsp;{if $REQ.extensionModule}{$REQ.extensionModule}{else}{vtranslate({$PAGETITLE}, $QUALIFIED_MODULE)}{/if}
+								&nbsp;{if $REQ->get('extensionModule')}{$REQ->get('extensionModule')}{else}{vtranslate({$PAGETITLE}, $QUALIFIED_MODULE)}{/if}
 							{/if}
 						</span>
 					{else}
-						{if $REQ.view eq 'TaxIndex'}
+						{if $REQ->get('view') eq 'TaxIndex'}
 							{assign var=SELECTED_MODULE value='LBL_TAX_MANAGEMENT'}
-						{elseif $REQ.view eq 'TermsAndConditionsEdit'}
+						{elseif $REQ->get('view') eq 'TermsAndConditionsEdit'}
 							{assign var=SELECTED_MODULE value='LBL_TERMS_AND_CONDITIONS'}
 						{else}
 							{assign var=SELECTED_MODULE value=$ACTIVE_BLOCK['menu']}
diff --git a/layouts/v7/modules/Vtiger/ModuleHeader.tpl b/layouts/v7/modules/Vtiger/ModuleHeader.tpl
index 612d24d22..db376c646 100644
--- a/layouts/v7/modules/Vtiger/ModuleHeader.tpl
+++ b/layouts/v7/modules/Vtiger/ModuleHeader.tpl
@@ -10,7 +10,7 @@
 {strip}
 	<div class="col-sm-11 col-xs-10 padding0 module-action-bar clearfix coloredBorderTop">
 		<div class="module-action-content clearfix {$MODULE}-module-action-content">
-			<div class="col-lg-7 col-md-6 col-sm-5 col-xs-11 padding0 module-breadcrumb module-breadcrumb-{$REQ.view} transitionsAllHalfSecond">
+			<div class="col-lg-7 col-md-6 col-sm-5 col-xs-11 padding0 module-breadcrumb module-breadcrumb-{$REQ->get('view')} transitionsAllHalfSecond">
 				{assign var=MODULE_MODEL value=Vtiger_Module_Model::getInstance($MODULE)}
 				{if $MODULE_MODEL->getDefaultViewName() neq 'List'}
 					{assign var=DEFAULT_FILTER_URL value=$MODULE_MODEL->getDefaultUrl()}
@@ -39,12 +39,12 @@
 					<p class="current-filter-name filter-name pull-left cursorPointer" title="{$CVNAME}"><span class="fa fa-angle-right pull-left" aria-hidden="true"></span><a href='{$MODULE_MODEL->getListViewUrl()}&viewname={$VIEWID}&app={$SELECTED_MENU_CATEGORY}'>&nbsp;&nbsp;{$CVNAME}&nbsp;&nbsp;</a> </p>
 				{/if}
 				{assign var=SINGLE_MODULE_NAME value='SINGLE_'|cat:$MODULE}
-				{if isset($RECORD) && $RECORD and $REQ.view eq 'Edit'}
+				{if isset($RECORD) && $RECORD and $REQ->get('view') eq 'Edit'}
 					<p class="current-filter-name filter-name pull-left "><span class="fa fa-angle-right pull-left" aria-hidden="true"></span><a title="{$RECORD->get('label')}">&nbsp;&nbsp;{vtranslate('LBL_EDITING', $MODULE)} : {$RECORD->get('label')} &nbsp;&nbsp;</a></p>
-				{else if $REQ.view eq 'Edit'}
+				{else if $REQ->get('view') eq 'Edit'}
 					<p class="current-filter-name filter-name pull-left "><span class="fa fa-angle-right pull-left" aria-hidden="true"></span><a>&nbsp;&nbsp;{vtranslate('LBL_ADDING_NEW', $MODULE)}&nbsp;&nbsp;</a></p>
 				{/if}
-				{if $REQ.view eq 'Detail'}
+				{if $REQ->get('view') eq 'Detail'}
 					<p class="current-filter-name filter-name pull-left"><span class="fa fa-angle-right pull-left" aria-hidden="true"></span><a title="{$RECORD->get('label')}">&nbsp;&nbsp;{$RECORD->get('label')} &nbsp;&nbsp;</a></p>
 				{/if}
 			</div>
-- 
GitLab