Single quotes in datetime fields labels gives Javascript Errors #4790

Open
opened 2026-02-20 16:23:57 -05:00 by deekerman · 1 comment
Owner

Originally created by @SinergiaCRM on GitHub (Jun 17, 2022).

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:
github.com/SinergiaTIC/SinergiaCRM-SuiteCRM@0de1deefab/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:
github.com/SinergiaTIC/SinergiaCRM-SuiteCRM@0de1deefab/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

Originally created by @SinergiaCRM on GitHub (Jun 17, 2022). 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](https://user-images.githubusercontent.com/61022311/174267456-62e79d35-03c7-4df5-9de9-e310ed08f744.png) #### Context Datetime fields should work as any other module #### Your Environment <!--- Include as many relevant details about the environment you experienced the bug in --> 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
Author
Owner

@SinergiaCRM commented on GitHub (Aug 1, 2022):

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

@SinergiaCRM commented on GitHub (Aug 1, 2022): The Pr wasn't correctly linked. Please see PR https://github.com/salesagility/SuiteCRM/pull/9624
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SuiteCRM-SuiteCRM#4790
No description provided.