Index: deployment/common/src/main/resources/com/sun/logging/enterprise/system/tools/deployment/LogStrings.properties =================================================================== --- deployment/common/src/main/resources/com/sun/logging/enterprise/system/tools/deployment/LogStrings.properties (revision 26577) +++ deployment/common/src/main/resources/com/sun/logging/enterprise/system/tools/deployment/LogStrings.properties (working copy) @@ -184,19 +184,19 @@ DPL8012.diag.cause.1="Failed to rename directory" DPL8012.diag.cause.2="May be because of lack of permissions" DPL8012.diag.check.1="Ensure that the permissions are set as expected" -DPL8012.diag.check.2="Ensure that the there is no directory name clash" +DPL8012.diag.check.2="Ensure that there is no directory name clash" enterprise.deployment.backend.jarCreationFailure="DPL8013: JAR file creation failure : {0}" DPL8013.diag.cause.1="Failed to create JAR file" DPL8013.diag.cause.2="May be because of lack of permissions or lack of space" DPL8013.diag.check.1="Ensure that the permissions are set as expected" -DPL8013.diag.check.2="Ensure that the there is enough space" +DPL8013.diag.check.2="Ensure that there is enough space" enterprise.deployment.backend.appDeploymentFailure="DPL8014: Application deployment failure" DPL8014.diag.cause.1="Failed to complete application deployment" DPL8014.diag.cause.2="May be because of lack of permissions or lack of space or wrong application" DPL8014.diag.check.1="Ensure that the permissions are set as expected" -DPL8014.diag.check.2="Ensure that the there is enough space" +DPL8014.diag.check.2="Ensure that there is enough space" enterprise.deployment.backend.invalidDescriptorFailure="DPL8015: Invalid Deployment Descriptors in {0} \nLine {1} Column {2} -- {3}" DPL8015.diag.cause.1="Failed to find the resource specified in the deployment descriptor" @@ -225,3 +225,4 @@ DPL8021.diag.check.1="Ensure that the resource specified is a valid URL" DPL8021.diag.check.2="Ensure that there is no typo in the resource specified in the descriptor" deployment.no_xmldir=DPL8022: Failed to load deployment descriptor files from directory: {0}. Load them from directory : {1} instead. +enterprise.deployment.backend.urlcontainscrlf="DPL8023: URL Pattern contains CR(#xD) or LF(#xA): [{0}]. Leading and trailing whitespace will be ignored." Index: deployment/dol/src/main/java/com/sun/enterprise/deployment/node/web/ServletMappingNode.java =================================================================== --- deployment/dol/src/main/java/com/sun/enterprise/deployment/node/web/ServletMappingNode.java (revision 26577) +++ deployment/dol/src/main/java/com/sun/enterprise/deployment/node/web/ServletMappingNode.java (working copy) @@ -72,6 +72,26 @@ servletName = value; } if (WebTagNames.URL_PATTERN.equals(element.getQName())) { + if (!URLPattern.isValid(value)) { + // try trimming url (in case DD uses extra whitespace for + // aligning) + String trimmedUrl = value.trim(); + if (URLPattern.isValid(trimmedUrl)) { + // warn user with error message if url included \r or \n + if (URLPattern.containsCRorLF(value)) { + DOLUtils.getDefaultLogger().log(Level.WARNING, + "enterprise.deployment.backend.urlcontainscrlf", + new Object[] { value }); + } + value = trimmedUrl; + } else { + throw new IllegalArgumentException(localStrings + .getLocalString( + "enterprise.deployment.invalidurlpattern", + "Invalid URL Pattern: [{0}]", + new Object[] { value })); + } + } // If URL Pattern does not start with "/" then // prepend it (for Servlet2.2 Web apps) Object parent = getParentNode().getDescriptor(); @@ -83,12 +103,6 @@ } } urlPattern = value; - if (!URLPattern.isValid(urlPattern)) { - throw new IllegalArgumentException(localStrings.getLocalString( - "enterprise.deployment.invalidurlpattern", - "Invalid URL Pattern: [{0}]", - new Object[] {urlPattern})); - } XMLNode parentNode = getParentNode(); if (parentNode instanceof WebBundleNode) { Index: deployment/dol/src/main/java/com/sun/enterprise/deployment/node/web/WebResourceCollectionNode.java =================================================================== --- deployment/dol/src/main/java/com/sun/enterprise/deployment/node/web/WebResourceCollectionNode.java (revision 26577) +++ deployment/dol/src/main/java/com/sun/enterprise/deployment/node/web/WebResourceCollectionNode.java (working copy) @@ -41,6 +41,7 @@ import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; import com.sun.enterprise.deployment.node.DescriptorFactory; import com.sun.enterprise.deployment.node.XMLElement; +import com.sun.enterprise.deployment.util.DOLUtils; import com.sun.enterprise.deployment.xml.WebTagNames; import com.sun.enterprise.util.LocalStringManagerImpl; import com.sun.enterprise.util.net.URLPattern; @@ -48,6 +49,7 @@ import java.util.Enumeration; import java.util.Map; +import java.util.logging.Level; /** * This nodes handles the web-collection xml tag element @@ -100,6 +102,26 @@ */ public void setElementValue(XMLElement element, String value) { if (WebTagNames.URL_PATTERN.equals(element.getQName())) { + if (!URLPattern.isValid(value)) { + // try trimming url (in case DD uses extra whitespace for + // aligning) + String trimmedUrl = value.trim(); + if (URLPattern.isValid(trimmedUrl)) { + // warn user with error message if url included \r or \n + if (URLPattern.containsCRorLF(value)) { + DOLUtils.getDefaultLogger().log(Level.WARNING, + "enterprise.deployment.backend.urlcontainscrlf", + new Object[] { value }); + } + value = trimmedUrl; + } else { + throw new IllegalArgumentException(localStrings + .getLocalString( + "enterprise.deployment.invalidurlpattern", + "Invalid URL Pattern: [{0}]", + new Object[] { value })); + } + } // If URL Pattern does not start with "/" then // prepend it (for Servlet2.2 Web apps) Object parent = getParentNode().getParentNode().getDescriptor(); @@ -110,12 +132,6 @@ value = "/" + value; } } - if (!URLPattern.isValid(value)) { - throw new IllegalArgumentException(localStrings.getLocalString( - "enterprise.deployment.invalidurlpattern", - "Invalid URL Pattern: [{0}]", - new Object[] {value})); - } descriptor.addUrlPattern(value); } else super.setElementValue(element, value); } Index: deployment/dol/src/main/java/com/sun/enterprise/deployment/node/web/FilterMappingNode.java =================================================================== --- deployment/dol/src/main/java/com/sun/enterprise/deployment/node/web/FilterMappingNode.java (revision 26577) +++ deployment/dol/src/main/java/com/sun/enterprise/deployment/node/web/FilterMappingNode.java (working copy) @@ -46,6 +46,7 @@ import com.sun.enterprise.deployment.WebBundleDescriptor; import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; import com.sun.enterprise.deployment.node.XMLElement; +import com.sun.enterprise.deployment.util.DOLUtils; import com.sun.enterprise.deployment.xml.WebTagNames; import com.sun.enterprise.util.LocalStringManagerImpl; import com.sun.enterprise.util.net.URLPattern; @@ -54,6 +55,7 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; +import java.util.logging.Level; import javax.servlet.DispatcherType; @@ -103,6 +105,26 @@ if (WebTagNames.SERVLET_NAME.equals(element.getQName())) { descriptor.addServletName(value); } else if (WebTagNames.URL_PATTERN.equals(element.getQName())) { + if (!URLPattern.isValid(value)) { + // try trimming url (in case DD uses extra whitespace for + // aligning) + String trimmedUrl = value.trim(); + if (URLPattern.isValid(trimmedUrl)) { + // warn user with error message if url included \r or \n + if (URLPattern.containsCRorLF(value)) { + DOLUtils.getDefaultLogger().log(Level.WARNING, + "enterprise.deployment.backend.urlcontainscrlf", + new Object[] { value }); + } + value = trimmedUrl; + } else { + throw new IllegalArgumentException(localStrings + .getLocalString( + "enterprise.deployment.invalidurlpattern", + "Invalid URL Pattern: [{0}]", + new Object[] { value })); + } + } // If URL Pattern does not start with "/" then // prepend it (for Servlet2.2 Web apps) Object parent = getParentNode().getDescriptor(); @@ -113,13 +135,6 @@ value = "/" + value; } } - - if (!URLPattern.isValid(value)) { - throw new IllegalArgumentException(localStrings.getLocalString( - "enterprise.deployment.invalidurlpattern", - "Invalid URL Pattern: [{0}]", - new Object[] {value})); - } descriptor.addURLPattern(value); } else if (WebTagNames.DISPATCHER.equals(element.getQName())) { descriptor.addDispatcher(value); Index: web/web-glue/src/main/java/com/sun/enterprise/web/stats/StatsUtil.java =================================================================== --- web/web-glue/src/main/java/com/sun/enterprise/web/stats/StatsUtil.java (revision 26577) +++ web/web-glue/src/main/java/com/sun/enterprise/web/stats/StatsUtil.java (working copy) @@ -230,7 +230,7 @@ } } - return total/num; + return (num > 0 ? total/num : 0); } Index: common/common-util/src/main/java/com/sun/enterprise/util/net/URLPattern.java =================================================================== --- common/common-util/src/main/java/com/sun/enterprise/util/net/URLPattern.java (revision 26577) +++ common/common-util/src/main/java/com/sun/enterprise/util/net/URLPattern.java (working copy) @@ -62,7 +62,7 @@ public static boolean isValid(String urlPattern) { // URL Pattern should not contain New Line (NL) or // Carriage Return (CR) - if (urlPattern.indexOf(NL) != -1 || urlPattern.indexOf (CR) != -1) { + if (containsCRorLF(urlPattern)) { return false; } @@ -83,4 +83,17 @@ } } + + /** + * This method is used to check whether a url pattern contains a CR(#xD) or + * LF (#xA). According to the Servlet spec the developer must be informed + * when it does. + * + * @param urlPattern + * the url pattern (must not be null) + * @return true if it contains one or more CRs or LFs + */ + public static boolean containsCRorLF(String urlPattern) { + return (urlPattern.indexOf(NL) != -1 || urlPattern.indexOf (CR) != -1); + } }