Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3205

Escaped apostrophe in property files

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.1.6
    • Fix Version/s: Future
    • Component/s: Other
    • Labels:
      None

      Description

      My application contains both struts(1) and strust2 pages, and all the pages use the same property files as resource bundle. Some of the localized texts are used in javascript for both struts1 and struts2 pages. I have a problem with rendering the localized texts which contain apostrophes.

      For example I have the following "base" text: Vue d'ensemble de la page

      Because this localized text will be used in the JavaScript the result of rendering the tags should be:
      Vue d\'ensemble de la page
      (apostrophe escaped for javascript)

      In the strus1 jsp page (somewhere in a javascipt JSON table) I have:
      "<bean:message bundle='Struts2Resources' key='menu.item.home.tt'/>"

      To obtain the expected result for this tag in the property file I should have:
      'menu.item.home.tt=Vue d
      'ensemble de la page

      Similarly in the strus2 jsp page (somewhere in a javascipt JSON table) I have:
      "<s:text name='menu.item.home.tt'/>"

      To obtain the expected result for this tag in the property file I should have:
      'menu.item.home.tt=Vue d
      ''ensemble de la page

      In the first case the result in the struts2 page will be
      Vue d\ensemble de la page
      i.e. the apostrophe disappear

      In the second case the result in the struts1 page will be
      Vue d\''ensemble de la page
      which result in javascript error.

      I don't really understand why is the behavior different for these tags because I suppose that at the background both use the same JDK ResourceBundles. Please suggest an escaping solution which should work for both struts1 and struts2 tags.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              tamasruff Tamas Ruff
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: