SuiteCRM
SuiteCRM copied to clipboard
Single quotes in datetime fields labels gives Javascript Errors
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
- Create a datetime field in Contacts module
- Add the field to Contacts EditView
- Modify the Label manually in the code and add a single quote
- Go to Contacts Editview and check the error in the console
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
The Pr wasn't correctly linked. Please see PR https://github.com/salesagility/SuiteCRM/pull/9624