Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-6058

javascript internationalized strings must be escaped

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.1.3
    • Fix Version/s: 3.2
    • Component/s: Core CiviCRM
    • Labels:
      None

      Description

      Javascript internationalized strings must be escaped since the translation may contain quotes.

      For example, let's open templates/CRM/common/enableDisable.tpl:

      var text = '

      {ts}Enable Record{/ts}';

      becomes in french

      var text = 'Activer l'enregistrement'; <== error! There is a quote in the string...

      I added a new Smarty block called escapejs. Now the string is escaped:

      var text = '{escapejs}{ts}

      Enable Record

      {/ts}{/escapejs}';
      becomes
      var text = 'Activer l\'enregistrement'; <== OK!

      If this solution is accepted, it is necessary to add the {escapejs} block to each template containing inline javascript.

      Another way to do it would be to add a parameter to the {ts} block:

      var text = '{ts escapejs=true}Enable Record{/ts}

      ';

      What do you think about it?

        Attachments

          Activity

            People

            • Assignee:
              shot Piotr Szotkowski
              Reporter:
              cbenz Christophe Benz
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: