Grails
  1. Grails
  2. GRAILS-5576

In scaffolded edit form, <, >, & and é are replaced by &lt; &gt; &amp; and &eacute;

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 1.1.2
    • Fix Version/s: None
    • Component/s: Scaffolding
    • Labels:
      None

      Description

      Scaffolded edit page gives:

      <g:textField name="name" value="$

      {fieldValue(bean: beanInstance, field: 'name')}

      " />

      fieldValue encodes the field value as XML, translating < into < etc.

      This is correct if you put the field value as text on your web page.

      However, in the above case, it is wrong. The user will actually see the value with < in it, and if the user saves the domain class, the property will change to <. If the user does this again, it will change to &lt;. Etc.

      A workaround is to enter:

      <g:textField name="name" value="$

      {beanInstance.name}

      " />

      I'm not sure if the workaround is perfect, but it worked for me. If it is perfect, it should be in the standard scaffold templates too.

        Activity

        Hide
        Michel Vollebregt added a comment -

        In the above message, unfortunately some encoding happened as well.

        You should read on the 3rd line:

        translating < into &lt; etc.

        On the 5th line

        The user will actually see the value with &lt; in it, ... the property will change to &lt; ... it will change to &amp;&lt;

        Show
        Michel Vollebregt added a comment - In the above message, unfortunately some encoding happened as well. You should read on the 3rd line: translating < into &lt; etc. On the 5th line The user will actually see the value with &lt; in it, ... the property will change to &lt; ... it will change to &amp;&lt;
        Hide
        girino vey added a comment -

        I just reported a bug GRAILS-5668, that seems to be a duplicate of this one. What is happening is that html escaping is happening twice: one in the <g:textArea> tag (or <g:textField> tag) and once again on the use of the $

        {fieldValue()} function.

        The solution I found was to install the templates with "grails install-templates" and edit the src/templates/scaffolding/renderEditor.template removing the calls to ${fieldValue()}

        function.

        Show
        girino vey added a comment - I just reported a bug GRAILS-5668 , that seems to be a duplicate of this one. What is happening is that html escaping is happening twice: one in the <g:textArea> tag (or <g:textField> tag) and once again on the use of the $ {fieldValue()} function. The solution I found was to install the templates with "grails install-templates" and edit the src/templates/scaffolding/renderEditor.template removing the calls to ${fieldValue()} function.
        Hide
        cdeszaq added a comment -

        I believe this can be closed as a duplicate.

        Show
        cdeszaq added a comment - I believe this can be closed as a duplicate.

          People

          • Assignee:
            Unassigned
            Reporter:
            Michel Vollebregt
          • Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Last Reviewed:

              Development