ICEfaces
  1. ICEfaces
  2. ICE-10155

Backslashes not being converted properly in DOM diffs

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: EE-3.3.0.GA_P02
    • Fix Version/s: 4.0, EE-3.3.0.GA_P03
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      n/a

      Description

      Backslashes in select option values are causing unnecessary DOM diffs. The DOM diff is always showing properly escaped backslashes (\\) in the previous DOM, but not in the new DOM. The difference between '\\' and '\' is then detected during the diff and the select element options will always be included in the diff, even if nothing has changed in the rendering.

      debug A:
       element[tag: select; attributes: id=j_idt4:_t5 name=j_idt4:_t5 onchange=mojarra.ab(this,event,'change','@this','@all') size=1 ]
              text[ <option value="" selected="true">Please select one..</option>
        <option value="A">A</option>
        <option value="B">B</option>
        <option value="This is a backslash: \">This is a backslash: \\</option>

      debug B:
      element[tag: select; attributes: id=j_idt4:_t5 name=j_idt4:_t5 onchange=mojarra.ab(this,event,'change','@this','@all') size=1 ]
              text[ <option value="" selected="true">Please select one..</option>
        <option value="A">A</option>
        <option value="B">B</option>
        <option value="This is a backslash: \">This is a backslash: \</option>

      This issue with backslashes seems to only occur with select elements, and not in other text nodes or element attributes. InputText components and free-standing text with backslashes appears unaffected.

      A simple workaround is to include a String converter in the select component that will replace the backslash with a unicode character:

      public String getAsString(FacesContext context, UIComponent component,
      Object value) throws ConverterException {
      if( value != null && value instanceof String){
      value = ((String)value).replace("\\", "&#x5C;");
      }

      return (String)value;
      }

        Activity

        Philip Breau created issue -
        Philip Breau made changes -
        Field Original Value New Value
        Attachment blackslash-test.war [ 17302 ]
        Attachment backslash-node-diff.txt [ 17303 ]
        Philip Breau made changes -
        Description Backslashes in select option values are causing unnecessary DOM diffs. The DOM diff is always showing properly escaped backslashes (\\) in the previous DOM, but not in the new DOM. The difference between '\\' and '\' is then detected during the diff and the select element options will always be included in the diff, even if nothing has changed in the rendering.

        This issue with backslashes seems to only occur with select elements, and not in other text nodes or element attributes. InputText components and free-standing text with backslashes appears unaffected.

        A simple workaround is to include a String converter in the select component that will replace the backslash with a unicode character:

        public String getAsString(FacesContext context, UIComponent component,
        Object value) throws ConverterException {
        if( value != null && value instanceof String){
        System.out.println("backslashStringConverter converting string");
        value = ((String)value).replace("\\", "&#x5C;");
        }

        return (String)value;
        }
        Backslashes in select option values are causing unnecessary DOM diffs. The DOM diff is always showing properly escaped backslashes (\\) in the previous DOM, but not in the new DOM. The difference between '\\' and '\' is then detected during the diff and the select element options will always be included in the diff, even if nothing has changed in the rendering.

        debug A:
         element[tag: select; attributes: id=j_idt4:_t5 name=j_idt4:_t5 onchange=mojarra.ab(this,event,'change','@this','@all') size=1 ]
                text[ <option value="" selected="true">Please select one..</option>
          <option value="A">A</option>
          <option value="B">B</option>
          <option value="This is a backslash: \">This is a backslash: \\</option>

        debug B:
        element[tag: select; attributes: id=j_idt4:_t5 name=j_idt4:_t5 onchange=mojarra.ab(this,event,'change','@this','@all') size=1 ]
                text[ <option value="" selected="true">Please select one..</option>
          <option value="A">A</option>
          <option value="B">B</option>
          <option value="This is a backslash: \">This is a backslash: \</option>

        This issue with backslashes seems to only occur with select elements, and not in other text nodes or element attributes. InputText components and free-standing text with backslashes appears unaffected.

        A simple workaround is to include a String converter in the select component that will replace the backslash with a unicode character:

        public String getAsString(FacesContext context, UIComponent component,
        Object value) throws ConverterException {
        if( value != null && value instanceof String){
        System.out.println("backslashStringConverter converting string");
        value = ((String)value).replace("\\", "&#x5C;");
        }

        return (String)value;
        }
        Philip Breau made changes -
        Description Backslashes in select option values are causing unnecessary DOM diffs. The DOM diff is always showing properly escaped backslashes (\\) in the previous DOM, but not in the new DOM. The difference between '\\' and '\' is then detected during the diff and the select element options will always be included in the diff, even if nothing has changed in the rendering.

        debug A:
         element[tag: select; attributes: id=j_idt4:_t5 name=j_idt4:_t5 onchange=mojarra.ab(this,event,'change','@this','@all') size=1 ]
                text[ <option value="" selected="true">Please select one..</option>
          <option value="A">A</option>
          <option value="B">B</option>
          <option value="This is a backslash: \">This is a backslash: \\</option>

        debug B:
        element[tag: select; attributes: id=j_idt4:_t5 name=j_idt4:_t5 onchange=mojarra.ab(this,event,'change','@this','@all') size=1 ]
                text[ <option value="" selected="true">Please select one..</option>
          <option value="A">A</option>
          <option value="B">B</option>
          <option value="This is a backslash: \">This is a backslash: \</option>

        This issue with backslashes seems to only occur with select elements, and not in other text nodes or element attributes. InputText components and free-standing text with backslashes appears unaffected.

        A simple workaround is to include a String converter in the select component that will replace the backslash with a unicode character:

        public String getAsString(FacesContext context, UIComponent component,
        Object value) throws ConverterException {
        if( value != null && value instanceof String){
        System.out.println("backslashStringConverter converting string");
        value = ((String)value).replace("\\", "&#x5C;");
        }

        return (String)value;
        }
        Backslashes in select option values are causing unnecessary DOM diffs. The DOM diff is always showing properly escaped backslashes (\\) in the previous DOM, but not in the new DOM. The difference between '\\' and '\' is then detected during the diff and the select element options will always be included in the diff, even if nothing has changed in the rendering.

        debug A:
         element[tag: select; attributes: id=j_idt4:_t5 name=j_idt4:_t5 onchange=mojarra.ab(this,event,'change','@this','@all') size=1 ]
                text[ <option value="" selected="true">Please select one..</option>
          <option value="A">A</option>
          <option value="B">B</option>
          <option value="This is a backslash: \">This is a backslash: \\</option>

        debug B:
        element[tag: select; attributes: id=j_idt4:_t5 name=j_idt4:_t5 onchange=mojarra.ab(this,event,'change','@this','@all') size=1 ]
                text[ <option value="" selected="true">Please select one..</option>
          <option value="A">A</option>
          <option value="B">B</option>
          <option value="This is a backslash: \">This is a backslash: \</option>

        This issue with backslashes seems to only occur with select elements, and not in other text nodes or element attributes. InputText components and free-standing text with backslashes appears unaffected.

        A simple workaround is to include a String converter in the select component that will replace the backslash with a unicode character:

        public String getAsString(FacesContext context, UIComponent component,
        Object value) throws ConverterException {
        if( value != null && value instanceof String){
        value = ((String)value).replace("\\", "&#x5C;");
        }

        return (String)value;
        }
        Arran Mccullough made changes -
        Support Case References Support Case #12971 - https://icesoft.my.salesforce.com/5007000000fDO3P
        Deryk Sinotte made changes -
        Assignee Mircea Toma [ mircea.toma ]
        Fix Version/s EE-3.3.0.GA_P03 [ 11572 ]
        Assignee Priority P2 [ 10011 ]
        Ken Fyten made changes -
        Fix Version/s 4.0 [ 11382 ]
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #42101 Wed Aug 13 14:17:09 MDT 2014 mircea.toma ICE-10155 Modified DOMPartialViewContext.applyBrowserChanges method to replace quote (") characters with their Regex equivalent (\") when calling Matcher.appendReplacement to avoid having the backslashes found in the DOM attributes interpreted as an escape characters for the quotes.
        Files Changed
        Commit graph MODIFY /icefaces4/trunk/icefaces/core/src/main/java/org/icefaces/impl/context/DOMPartialViewContext.java
        Hide
        Mircea Toma added a comment -

        Modified DOMPartialViewContext.applyBrowserChanges method to replace quote (") characters with their Regex equivalent (\") when calling Matcher.appendReplacement to avoid having the backslashes found in the DOM attributes interpreted as an escape characters for the quotes.

        Show
        Mircea Toma added a comment - Modified DOMPartialViewContext.applyBrowserChanges method to replace quote (") characters with their Regex equivalent (\") when calling Matcher.appendReplacement to avoid having the backslashes found in the DOM attributes interpreted as an escape characters for the quotes.
        Mircea Toma made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #42105 Wed Aug 13 18:23:19 MDT 2014 mircea.toma ICE-10155 Modified core bridge to make public the general callbacks registered with the JSF bridge. Modified fielEntry's submission to invoke these callbacks at the appropriate moments during request-response processing.
        Files Changed
        Commit graph MODIFY /icefaces4/trunk/icefaces/core/src/main/javascript/application.js
        Commit graph MODIFY /icefaces4/trunk/icefaces/ace/component/resources/icefaces.ace/fileentry/fileEntry.js
        Ken Fyten made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Mircea Toma
            Reporter:
            Philip Breau
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: