diff --git a/include/utils/VtlibUtils.php b/include/utils/VtlibUtils.php index d31e2a0742f6d45ebdde872f8199fdea1bc346fb..41733b7136f3e29ea71555582ec828dec851e4b3 100644 --- a/include/utils/VtlibUtils.php +++ b/include/utils/VtlibUtils.php @@ -1031,4 +1031,12 @@ function php7_sizeof($value) { return php7_count($value); } -?> +function php7_trim($str) { + // PHP 8.x marks as deprecated + return $str == null ? $str : trim($str); +} + +function php7_htmlentities($str) { + // PHP 8.x marks as deprecated + return $str == null ? $str : htmlentities($str); +} diff --git a/includes/runtime/Viewer.php b/includes/runtime/Viewer.php index 59876ddfd84e4a5fdb64324aef93041bdbb07aad..9c64e39d349d56bad69888c7f81664271a341035 100644 --- a/includes/runtime/Viewer.php +++ b/includes/runtime/Viewer.php @@ -87,7 +87,7 @@ class Vtiger_Viewer extends Smarty { $modifiers = array('vtranslate', 'vtlib_isModuleActive', 'vimage_path', 'strstr', 'stripos', 'strpos', 'date', 'vtemplate_path', 'vresource_url', 'decode_html', 'vtlib_purify', 'php7_count', 'getUserFullName', 'array_flip', 'explode', 'trim', 'array_push', 'array_map', 'array_key_exists', 'get_class', 'vtlib_array', 'getDuplicatesPreventionMessage', 'htmlentities', - 'getCurrencySymbolandCRate', 'mb_substr', 'isPermitted', 'getEntityName', 'function_exists', + 'getCurrencySymbolandCRate', 'mb_substr', 'isPermitted', 'getEntityName', 'function_exists', 'php7_trim', 'php7_htmlentities', 'strtolower', 'strtoupper', 'str_replace', 'urlencode', 'getTranslatedCurrencyString', 'getTranslatedString', 'is_object', 'is_numeric'); foreach ($modifiers as $modifier) { if (function_exists($modifier)) { diff --git a/layouts/v7/modules/Vtiger/uitypes/Picklist.tpl b/layouts/v7/modules/Vtiger/uitypes/Picklist.tpl index e5a4898804d02b88764e3c7f88ec9686c22ca6a0..4a32603065f8238a958cafe6b5c9865651030979 100644 --- a/layouts/v7/modules/Vtiger/uitypes/Picklist.tpl +++ b/layouts/v7/modules/Vtiger/uitypes/Picklist.tpl @@ -21,7 +21,7 @@ {if $FIELD_MODEL->isEmptyPicklistOptionAllowed()}<option value="">{vtranslate('LBL_SELECT_OPTION','Vtiger')}</option>{/if} {foreach item=PICKLIST_VALUE key=PICKLIST_NAME from=$PICKLIST_VALUES} {assign var=CLASS_NAME value="picklistColor_{$FIELD_MODEL->getFieldName()}_{$PICKLIST_NAME|replace:' ':'_'}"} - <option value="{Vtiger_Util_Helper::toSafeHTML($PICKLIST_NAME)}" {if isset($PICKLIST_COLORS[$PICKLIST_NAME]) && $PICKLIST_COLORS[$PICKLIST_NAME]}class="{$CLASS_NAME}"{/if} {if trim(decode_html($FIELD_MODEL->get('fieldvalue'))) eq trim($PICKLIST_NAME)} selected {/if}>{$PICKLIST_VALUE}</option> + <option value="{Vtiger_Util_Helper::toSafeHTML($PICKLIST_NAME)}" {if isset($PICKLIST_COLORS[$PICKLIST_NAME]) && $PICKLIST_COLORS[$PICKLIST_NAME]}class="{$CLASS_NAME}"{/if} {if php7_trim(decode_html($FIELD_MODEL->get('fieldvalue'))) eq php7_trim($PICKLIST_NAME)} selected {/if}>{$PICKLIST_VALUE}</option> {/foreach} </select> {if $PICKLIST_COLORS} diff --git a/layouts/v7/modules/Vtiger/uitypes/String.tpl b/layouts/v7/modules/Vtiger/uitypes/String.tpl index 0715088c31873131da5fdd3468be3f66c44fe27f..9ec1f6bea6865e942c03a9f0b8f7f2d158dac0b3 100644 --- a/layouts/v7/modules/Vtiger/uitypes/String.tpl +++ b/layouts/v7/modules/Vtiger/uitypes/String.tpl @@ -16,7 +16,7 @@ {if (!$FIELD_NAME)} {assign var="FIELD_NAME" value=$FIELD_MODEL->getFieldName()} {/if} - <input id="{$MODULE}_editView_fieldName_{$FIELD_NAME}" type="text" data-fieldname="{$FIELD_NAME}" data-fieldtype="string" class="inputElement {if $FIELD_MODEL->isNameField()}nameField{/if}" name="{$FIELD_NAME}" value="{decode_html($FIELD_MODEL->get('fieldvalue'))|htmlentities}" + <input id="{$MODULE}_editView_fieldName_{$FIELD_NAME}" type="text" data-fieldname="{$FIELD_NAME}" data-fieldtype="string" class="inputElement {if $FIELD_MODEL->isNameField()}nameField{/if}" name="{$FIELD_NAME}" value="{decode_html($FIELD_MODEL->get('fieldvalue'))|php7_htmlentities}" {if $FIELD_MODEL->get('uitype') eq '3' || $FIELD_MODEL->get('uitype') eq '4'|| $FIELD_MODEL->isReadOnly()} {if $FIELD_MODEL->get('uitype') neq '106'} readonly diff --git a/modules/Vtiger/uitypes/Date.php b/modules/Vtiger/uitypes/Date.php index 5b1b46126e37b540eab7c0be2a90a3ed85fc961a..357cf9cf95999b243da47e3c6bfde886512f315c 100644 --- a/modules/Vtiger/uitypes/Date.php +++ b/modules/Vtiger/uitypes/Date.php @@ -70,6 +70,7 @@ class Vtiger_Date_UIType extends Vtiger_Base_UIType { * @return converted value */ public function getEditViewDisplayValue($value) { + if ($value == null) return $value; if (empty($value) || $value === ' ') { $value = trim($value); $fieldInstance = $this->get('field')->getWebserviceFieldObject();