SuiteCRM icon indicating copy to clipboard operation
SuiteCRM copied to clipboard

Saving labels with quotes in ModuleBuilder gives error

Open SinergiaCRM opened this issue 2 years ago • 3 comments

When editing a label of a module in the ModuleBuilder that contains a apostrophe/single quote in a label of any other field, it will return an error. Checking the generated language file it can be observed that a syntax error appears in the generated file custom/modulebuilder/packages/test/modules/test/language/en_us.lang.php

Selection_617

Issue

Labels with single quotes are correctly parsed when editing a label in ModuleBuilder

Expected Behavior

Label modification should work properly, regardless of the content.

Actual Behavior

It appears a syntax error, and the user can't continue editing.

Possible Fix

Replace https://github.com/salesagility/SuiteCRM/blob/2134e9562775a9c95c97fc44667099c602c04960/include/utils/file_utils.php#L141-L143

by: $the_string .= "\$$the_name = " . var_export_helper($the_array) . ";";

Steps to Reproduce

  1. Add a single quote in a label of language file of a module created in Modulebuilder (example: custom/modulebuilder/packages/test/modules/test/language/en_us.lang.php). You need to replace the single quotes string delimiters by double quotes
  2. Go to ModuleBuilder and make any modification of a label of that module (Note that you might see this issue #9576)
  3. After saving the modification, check that an error appears
  4. Check manually the language file and observe that there is a syntax error.

Context

If the default labels are already using single-quotes, this is a troublesome issue

Your Environment

SuiteCRM Version used: Version 7.12.6 Browser name and version: Versión 100.0.4896.88 (Build oficial) (64 bit Environment name and version: MySQL, PHP 7 Operating System and version: Ubuntu 20.04

SinergiaCRM avatar Aug 01 '22 11:08 SinergiaCRM

Hey @SinergiaCRM

I've given this a few tries, but I'm unable to replicate this, I'm afraid

If I add a Special Character, ie: Quotation mark or Apostrophe, to a label, it seems to convert as expected in the language file.

ie: image

Becomes: image

I've given this a try in both 7.12.6 and 7.12.7, and I am still able to continue editing labels.


Do you know the exact version of PHP7 you used? I've used 7.4 when testing this.

Additionally, do you know if there are any specific steps to replicate, that are required? (ie: Module needs to be deployed first, then labels edited in studio / Module must NOT be deployed yet / etc)

Thanks again for your contributions!

johnM2401 avatar Aug 29 '22 11:08 johnM2401

Hi @johnM2401

We are testing in PHP 7.4.

I realized I didn't provide the right instructions. These are the steps to reproduce:

  • Edit manually in the code the language file of the newly built module (not-deployed) adding single quotes to a label. Ex: 'LBL_OPT_IN_PENDING_EMAIL_NOT_SENT' => 'Confirmació d\'autorització pendent, Confirmació d\'autorització no enviada' or 'LBL_OPT_IN_PENDING_EMAIL_NOT_SENT' => "Confirmació d'autorització pendent, Confirmació d'autorització no enviada", (In this first step, you can also edit the core-base language files that will be used by the ModuleBuilder to construct the new module include/SugarObjects/templates/basic/language/ca_ES.lang.php. Then build a new module)
  • Go to Module Builder (build a new module if you modified the core-base language files)
  • Go to the general label Editor Selection_635
  • Edit a label that doesn't contains single quotes and Save
  • Check that there is a syntax error in the result language file of the new module

SinergiaCRM avatar Aug 30 '22 08:08 SinergiaCRM

Hey @SinergiaCRM

Thank you for the additional information!

I'm now able to replicate this issue, so i'll mark this as a Bug.

Thank you again!

johnM2401 avatar Aug 30 '22 13:08 johnM2401