SuiteCRM icon indicating copy to clipboard operation
SuiteCRM copied to clipboard

Single quotes in datetime fields labels gives Javascript Errors

Open SinergiaCRM opened this issue 2 years ago • 1 comments

If a label of a Datetime field contains single quotes, instead of its html entity, directly in the code, it would give a Javascript error if the field is added in the Editview. The label should look like this:

$mod_strings['LBL_TEST'] = "T'est";

Expected Behavior

The single quotes should be escaped as in other field types

Actual Behavior

Single quotes in labels returns error in EditViews.

Possible Fix

Two steps: 1- For the ListView: Add slashes to datetime field labels, same as with date fields: https://github.com/SinergiaTIC/SinergiaCRM-SuiteCRM/blob/0de1deefab1c9d7eb14aec4f0103b4282ae77a84/include/MassUpdate.php#L1239-L1244

2- For the EditView: Translating Datetime string to smarty for avoiding single quote sintax errors. Replicating solution as in addField() function: https://github.com/SinergiaTIC/SinergiaCRM-SuiteCRM/blob/0de1deefab1c9d7eb14aec4f0103b4282ae77a84/include/javascript/javascript.php#L103-L112

Steps to Reproduce

  1. Create a datetime field in Contacts module
  2. Add the field to Contacts EditView
  3. Modify the Label manually in the code and add a single quote
  4. Go to Contacts Editview and check the error in the console Selection_583

Context

Datetime fields should work as any other module

Your Environment

SuiteCRM Version used: Version 7.12.6 Browser name and version: Chrome Versión 100.0.4896.88 (Build oficial) (64 bits), Firefox 100.0 Environment name and version: MySQL, PHP 7.4 Operating System and version: Ubuntu 20.04

SinergiaCRM avatar Jun 17 '22 09:06 SinergiaCRM

The Pr wasn't correctly linked. Please see PR https://github.com/salesagility/SuiteCRM/pull/9624

SinergiaCRM avatar Aug 01 '22 09:08 SinergiaCRM