From 6063898aa72db08371d1fab14239e5893caeb4a5 Mon Sep 17 00:00:00 2001 From: markt Date: Wed, 30 Dec 2009 12:02:26 +0000 Subject: [PATCH] Prevent definition of duplicate URIs for tag libraries and improve error messages for all duplicates git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@894599 13f79535-47bb-0310-9956-ffa450edef68 --- .../catalina/startup/LocalStrings.properties | 13 ++++++------ java/org/apache/catalina/startup/WebXml.java | 23 ++++++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/java/org/apache/catalina/startup/LocalStrings.properties b/java/org/apache/catalina/startup/LocalStrings.properties index 176d99e5d..315258abd 100644 --- a/java/org/apache/catalina/startup/LocalStrings.properties +++ b/java/org/apache/catalina/startup/LocalStrings.properties @@ -116,12 +116,13 @@ userConfig.start=UserConfig: Processing START userConfig.stop=UserConfig: Processing STOP webRuleSet.absoluteOrdering= element not valid in web-fragment.xml and will be ignored webRuleSet.relativeOrdering= element not valid in web.xml and will be ignored -webXml.duplicateEnvEntry=Duplicate env-entry name -webXml.duplicateFilter=Duplicate filter name -webXml.duplicateMessageDestination=Duplicate message-destination name -webXml.duplicateMessageDestinationRef=Duplicate message-destination-ref name -webXml.duplicateResourceEnvRef=Duplicate resource-env-ref name -webXml.duplicateResourceRef=Duplicate resource-ref name +webXml.duplicateEnvEntry=Duplicate env-entry name [{0}] +webXml.duplicateFilter=Duplicate filter name [{0}] +webXml.duplicateMessageDestination=Duplicate message-destination name [{0}] +webXml.duplicateMessageDestinationRef=Duplicate message-destination-ref name [{0}] +webXml.duplicateResourceEnvRef=Duplicate resource-env-ref name [{0}] +webXml.duplicateResourceRef=Duplicate resource-ref name [{0}] +webXml.duplicateTaglibUri=Duplicate tag library URI [{0}] webXml.reservedName=A web.xml file was detected using a reserved name [{0}]. The name element will be ignored for this fragment. webXml.mergeConflictDisplayName=The display name was defined in multiple fragments with different values including fragment with name [{0}] located at [{1}] webXml.mergeConflictErrorPage=The Error Page for [{0}] was defined inconsistently in multiple fragments including fragment with name [{1}] located at [{2}] diff --git a/java/org/apache/catalina/startup/WebXml.java b/java/org/apache/catalina/startup/WebXml.java index 598503102..fd0cc27dc 100644 --- a/java/org/apache/catalina/startup/WebXml.java +++ b/java/org/apache/catalina/startup/WebXml.java @@ -194,7 +194,8 @@ public class WebXml { if (filters.containsKey(filter.getFilterName())) { // Filter names must be unique within a web(-fragment).xml throw new IllegalArgumentException( - sm.getString("webXml.duplicateFilter")); + sm.getString("webXml.duplicateFilter", + filter.getFilterName())); } filters.put(filter.getFilterName(), filter); } @@ -279,6 +280,11 @@ public class WebXml { // jsp-config/taglib or taglib (2.3 and earlier) private Map taglibs = new HashMap(); public void addTaglib(String uri, String location) { + if (taglibs.containsKey(uri)) { + // Taglib URIs must be unique within a web(-fragment).xml + throw new IllegalArgumentException( + sm.getString("webXml.duplicateTaglibUri", uri)); + } taglibs.put(uri, location); } public Map getTaglibs() { return taglibs; } @@ -329,7 +335,8 @@ public class WebXml { if (envEntries.containsKey(envEntry.getName())) { // env-entry names must be unique within a web(-fragment).xml throw new IllegalArgumentException( - sm.getString("webXml.duplicateEnvEntry")); + sm.getString("webXml.duplicateEnvEntry", + envEntry.getName())); } envEntries.put(envEntry.getName(),envEntry); } @@ -373,7 +380,8 @@ public class WebXml { if (resourceRefs.containsKey(resourceRef.getName())) { // resource-ref names must be unique within a web(-fragment).xml throw new IllegalArgumentException( - sm.getString("webXml.duplicateResourceRef")); + sm.getString("webXml.duplicateResourceRef", + resourceRef.getName())); } resourceRefs.put(resourceRef.getName(), resourceRef); } @@ -389,7 +397,8 @@ public class WebXml { if (resourceEnvRefs.containsKey(resourceEnvRef.getName())) { // resource-env-ref names must be unique within a web(-fragment).xml throw new IllegalArgumentException( - sm.getString("webXml.duplicateResourceEnvRef")); + sm.getString("webXml.duplicateResourceEnvRef", + resourceEnvRef.getName())); } resourceEnvRefs.put(resourceEnvRef.getName(), resourceEnvRef); } @@ -408,7 +417,8 @@ public class WebXml { // message-destination-ref names must be unique within a // web(-fragment).xml throw new IllegalArgumentException(sm.getString( - "webXml.duplicateMessageDestinationRef")); + "webXml.duplicateMessageDestinationRef", + messageDestinationRef.getName())); } messageDestinationRefs.put(messageDestinationRef.getName(), messageDestinationRef); @@ -430,7 +440,8 @@ public class WebXml { // message-destination names must be unique within a // web(-fragment).xml throw new IllegalArgumentException( - sm.getString("webXml.duplicateMessageDestination")); + sm.getString("webXml.duplicateMessageDestination", + messageDestination.getName())); } messageDestinations.put(messageDestination.getName(), messageDestination); -- 2.11.0