Issue with SugarSmarty unknown modifier sugar_escape

Hi,

Has anyone experience issue with not being abled to create a customised field in Sugar?

Sugar log displays issue as:

Wed Jan 14 15:17:44 2026 [25][1][FATAL] Exception in Controller:  --> Smarty Compiler: Syntax error in template "file:/var/www/html/sugar/modules/DynamicFields/templates/Fields/Forms/varchar.tpl"  on line 20 "<input type="text" name="default" id="default" value="{$vardef.default|sugar_escape:'html':'UTF-8'}"" unknown modifier 'sugar_escape' <-- 

When I checked the folder Include/SugarSmarty, there was not any file with name modifier.sugar_escape.php. I added the file in manually but still the issue persist and Sugar log shows as the above.

Sugar version: 25.2.0

Pls reach out if you have any idea.

Thank you

Vy

Parents
  • I am on 25.1.0 and do have a file 

    include/SugarSmarty/plugins/modifier.sugar_escape.php

    I don't know if it was removed in 25.2.0 (we are on-site and that release is not for on-site customers).

    FWIW This is what it looks like in 25.1

    <?php
    /*
     * Your installation or use of this SugarCRM file is subject to the applicable
     * terms available at
     * http://support.sugarcrm.com/Resources/Master_Subscription_Agreements/.
     * If you do not agree to all of the applicable terms or do not have the
     * authority to bind the entity as an authorized representative, then do not
     * install or use this SugarCRM file.
     *
     * Copyright (C) SugarCRM Inc. All rights reserved.
     */
    /**
     * Escapes a string preventing double escaping
     * @param $string
     * @param $esc_type
     * @param $char_set
     * @param $double_encode
     * @return string
     */
    function smarty_modifier_sugar_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
    {
        do {
            $oldData = $string;
            $string = htmlspecialchars_decode($string, ENT_QUOTES);
        } while ($string !== $oldData);
        require_once 'vendor/smarty/smarty/libs/plugins/modifier.escape.php';
        return smarty_modifier_escape($string, $esc_type, $char_set, $double_encode);
    }
    

    Hope this helps you,

    FrancescaS

Reply
  • I am on 25.1.0 and do have a file 

    include/SugarSmarty/plugins/modifier.sugar_escape.php

    I don't know if it was removed in 25.2.0 (we are on-site and that release is not for on-site customers).

    FWIW This is what it looks like in 25.1

    <?php
    /*
     * Your installation or use of this SugarCRM file is subject to the applicable
     * terms available at
     * http://support.sugarcrm.com/Resources/Master_Subscription_Agreements/.
     * If you do not agree to all of the applicable terms or do not have the
     * authority to bind the entity as an authorized representative, then do not
     * install or use this SugarCRM file.
     *
     * Copyright (C) SugarCRM Inc. All rights reserved.
     */
    /**
     * Escapes a string preventing double escaping
     * @param $string
     * @param $esc_type
     * @param $char_set
     * @param $double_encode
     * @return string
     */
    function smarty_modifier_sugar_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
    {
        do {
            $oldData = $string;
            $string = htmlspecialchars_decode($string, ENT_QUOTES);
        } while ($string !== $oldData);
        require_once 'vendor/smarty/smarty/libs/plugins/modifier.escape.php';
        return smarty_modifier_escape($string, $esc_type, $char_set, $double_encode);
    }
    

    Hope this helps you,

    FrancescaS

Children