Skip to content

Single quotes in datetime fields labels gives Javascript Errors #9623

Open
@SinergiaCRM

Description

@SinergiaCRM

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: ModuleIssues & PRs related to modules that do not have specific labelStatus:Fix ProposedA issue that has a PR related to it that provides a possible resolutionType: BugBugs within the core SuiteCRM codebase

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions