ICEfaces
  1. ICEfaces
  2. ICE-1723

Auto-add single quotes to the connectionLostRedirectURI to avoid js errors

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6DR#5
    • Fix Version/s: 1.7.1
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      any

      Description

      If you specify the connectionLostRedirectURI in your web.xml and forget to single quote the URL, the resulting js configuration string will be corrupted. We should check for this when loading the parameter.

        Activity

        Ken Fyten made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Assignee Priority P2
        Assignee Mircea Toma [ mircea.toma ]
        Mircea Toma made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Mircea Toma added a comment -

        Add single quotes. Remove single quotes set by user.

        Show
        Mircea Toma added a comment - Add single quotes. Remove single quotes set by user.
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #16646 Wed May 14 15:56:11 MDT 2008 mircea.toma Add single quotes. Remove single quotes set by user. ICE-1723
        Files Changed
        Commit graph MODIFY /icefaces/branches/icefaces-1.7/icefaces/core/src/com/icesoft/faces/context/DOMResponseWriter.java
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #16645 Wed May 14 15:43:52 MDT 2008 mircea.toma Add single quotes. Remove single quotes set by user.
        ICE-1723
        Files Changed
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/context/DOMResponseWriter.java
        Ken Fyten made changes -
        Fix Version/s 1.7.1 [ 10122 ]
        Assignee Priority P2
        Assignee Mircea Toma [ mircea.toma ]
        Michael Thiem made changes -
        Ken Fyten made changes -
        Field Original Value New Value
        Priority Major [ 3 ] Minor [ 4 ]
        Hide
        Philip Breau added a comment -

        suggested fix:

        Index: C:/Users/Philip/workspace/ICEfaces Head/icefaces/core/src/com/icesoft/faces/context/DOMResponseWriter.java
        ===================================================================
        — C:/Users/Philip/workspace/ICEfaces Head/icefaces/core/src/com/icesoft/faces/context/DOMResponseWriter.java (revision 14269)
        +++ C:/Users/Philip/workspace/ICEfaces Head/icefaces/core/src/com/icesoft/faces/context/DOMResponseWriter.java (working copy)
        @@ -354,10 +354,15 @@
        ElementController.from(session).addInto(body);

        String sessionIDScript = "window.session='" + context.getIceFacesId() + "'; ";
        + String connectionLostRedirectURI = configuration.getAttributeAsSingleQuotedRelativeURL("connectionLostRedirectURI", "null");
        + if( connectionLostRedirectURI == null )

        { + log.warn( configuration.getAttribute("connectionLostRedirectURI","") + " is not a valid URL for 'connectionLostRedirectURI'"); + connectionLostRedirectURI = "null"; + }

        String configurationScript =
        "window.configuration = {" +
        "synchronous: " + configuration.getAttribute("synchronousUpdate", "false") + "," +

        • "redirectURI: " + configuration.getAttribute("connectionLostRedirectURI", "null") + "," +
          + "redirectURI: " + connectionLostRedirectURI + "," +
          "connection: {" +
          "context: '" + context.getApplication().getViewHandler().getResourceURL(context, "/") + "'," +
          "timeout: " + configuration.getAttributeAsLong("connectionTimeout", 30000) + "," +

        Index: C:/Users/Philip/workspace/ICEfaces Head/icefaces/core/src/com/icesoft/faces/webapp/http/common/Configuration.java
        ===================================================================
        — C:/Users/Philip/workspace/ICEfaces Head/icefaces/core/src/com/icesoft/faces/webapp/http/common/Configuration.java (revision 14269)
        +++ C:/Users/Philip/workspace/ICEfaces Head/icefaces/core/src/com/icesoft/faces/webapp/http/common/Configuration.java (working copy)
        @@ -1,5 +1,10 @@
        package com.icesoft.faces.webapp.http.common;

        +import java.util.regex.Pattern;
        +
        +import javax.faces.context.FacesContext;
        +
        +
        public abstract class Configuration

        { public abstract String getName(); @@ -147,4 +152,43 @@ return defaultValue; }

        }
        +
        + public String getAttributeAsSingleQuotedRelativeURL(String name, String defaultValue){
        + String result = defaultValue;
        + try{
        + result = getAttributeAsRelativeURL(name,defaultValue);
        + if( result != null && !result.equals(defaultValue))

        { + + //modify url to ensure it starts with '/ and ends with ' + if( result.startsWith("'")) + result = result.substring(1); + if( result.startsWith("/")) + result = result.substring(1); + result = "'/" + result; + if( !result.endsWith("'")) + result += "'"; + }

        + }
        + catch( ConfigurationException e)

        { + result = null; + }

        +
        + return result;
        + }
        +
        + public String getAttributeAsRelativeURL(String name, String defaultValue)
        + throws ConfigurationException{
        + String result = getAttribute(name);
        + if( result != null ){
        + result = result.trim();
        + if( ! Pattern.matches("^/\\S./+$", result) )

        { + throw new ConfigurationException( result + " is not a valid URL for " + name); + }

        +
        + return result;
        + }
        + return defaultValue;
        + }
        +
        +
        }

        Show
        Philip Breau added a comment - suggested fix: Index: C:/Users/Philip/workspace/ICEfaces Head/icefaces/core/src/com/icesoft/faces/context/DOMResponseWriter.java =================================================================== — C:/Users/Philip/workspace/ICEfaces Head/icefaces/core/src/com/icesoft/faces/context/DOMResponseWriter.java (revision 14269) +++ C:/Users/Philip/workspace/ICEfaces Head/icefaces/core/src/com/icesoft/faces/context/DOMResponseWriter.java (working copy) @@ -354,10 +354,15 @@ ElementController.from(session).addInto(body); String sessionIDScript = "window.session='" + context.getIceFacesId() + "'; "; + String connectionLostRedirectURI = configuration.getAttributeAsSingleQuotedRelativeURL("connectionLostRedirectURI", "null"); + if( connectionLostRedirectURI == null ) { + log.warn( configuration.getAttribute("connectionLostRedirectURI","") + " is not a valid URL for 'connectionLostRedirectURI'"); + connectionLostRedirectURI = "null"; + } String configurationScript = "window.configuration = {" + "synchronous: " + configuration.getAttribute("synchronousUpdate", "false") + "," + "redirectURI: " + configuration.getAttribute("connectionLostRedirectURI", "null") + "," + + "redirectURI: " + connectionLostRedirectURI + "," + "connection: {" + "context: '" + context.getApplication().getViewHandler().getResourceURL(context, "/") + "'," + "timeout: " + configuration.getAttributeAsLong("connectionTimeout", 30000) + "," + Index: C:/Users/Philip/workspace/ICEfaces Head/icefaces/core/src/com/icesoft/faces/webapp/http/common/Configuration.java =================================================================== — C:/Users/Philip/workspace/ICEfaces Head/icefaces/core/src/com/icesoft/faces/webapp/http/common/Configuration.java (revision 14269) +++ C:/Users/Philip/workspace/ICEfaces Head/icefaces/core/src/com/icesoft/faces/webapp/http/common/Configuration.java (working copy) @@ -1,5 +1,10 @@ package com.icesoft.faces.webapp.http.common; +import java.util.regex.Pattern; + +import javax.faces.context.FacesContext; + + public abstract class Configuration { public abstract String getName(); @@ -147,4 +152,43 @@ return defaultValue; } } + + public String getAttributeAsSingleQuotedRelativeURL(String name, String defaultValue){ + String result = defaultValue; + try{ + result = getAttributeAsRelativeURL(name,defaultValue); + if( result != null && !result.equals(defaultValue)) { + + //modify url to ensure it starts with '/ and ends with ' + if( result.startsWith("'")) + result = result.substring(1); + if( result.startsWith("/")) + result = result.substring(1); + result = "'/" + result; + if( !result.endsWith("'")) + result += "'"; + } + } + catch( ConfigurationException e) { + result = null; + } + + return result; + } + + public String getAttributeAsRelativeURL(String name, String defaultValue) + throws ConfigurationException{ + String result = getAttribute(name); + if( result != null ){ + result = result.trim(); + if( ! Pattern.matches("^/ \\S./ +$", result) ) { + throw new ConfigurationException( result + " is not a valid URL for " + name); + } + + return result; + } + return defaultValue; + } + + }
        Philip Breau created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Philip Breau
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: