JBossWeb SVN: r1088 - in trunk/java/org/apache/catalina: core and 1 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-06-06 18:18:39 -0400 (Sat, 06 Jun 2009)
New Revision: 1088
Modified:
trunk/java/org/apache/catalina/Context.java
trunk/java/org/apache/catalina/Globals.java
trunk/java/org/apache/catalina/core/StandardContext.java
trunk/java/org/apache/catalina/startup/WebRuleSet.java
Log:
- Add a Servlet version string.
Modified: trunk/java/org/apache/catalina/Context.java
===================================================================
--- trunk/java/org/apache/catalina/Context.java 2009-06-06 22:18:10 UTC (rev 1087)
+++ trunk/java/org/apache/catalina/Context.java 2009-06-06 22:18:39 UTC (rev 1088)
@@ -407,6 +407,20 @@
/**
+ * Return the Servlet API version defined for the webapp.
+ */
+ public String getVersion();
+
+
+ /**
+ * Set the Servlet API version defined for the webapp.
+ *
+ * @param version The version
+ */
+ public void setVersion(String version);
+
+
+ /**
* Return the reloadable flag for this web application.
*/
public boolean getReloadable();
Modified: trunk/java/org/apache/catalina/Globals.java
===================================================================
--- trunk/java/org/apache/catalina/Globals.java 2009-06-06 22:18:10 UTC (rev 1087)
+++ trunk/java/org/apache/catalina/Globals.java 2009-06-06 22:18:39 UTC (rev 1088)
@@ -157,12 +157,11 @@
/**
- * The servlet context attribute under which we record the set of
- * JSP tag libraries locations (as an object of type HashMap<String, String>)
- * for this application.
+ * The servlet context attribute under which we record the Servlet API version
+ * support declared for this webapp.
*/
- public static final String JSP_TAG_LIBRARIES_LOCATION =
- "org.apache.catalina.JSP_TAG_LIBRARIES_LOCATION";
+ public static final String SERVLET_VERSION =
+ "org.apache.catalina.SERVLET_VERSION";
/**
Modified: trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2009-06-06 22:18:10 UTC (rev 1087)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2009-06-06 22:18:39 UTC (rev 1088)
@@ -503,7 +503,13 @@
*/
protected String publicId = null;
+
+ /**
+ * Version number.
+ */
+ protected String version = null;
+
/**
* The reloadable flag for this web application.
*/
@@ -1582,6 +1588,26 @@
/**
+ * Return the Servlet API version defined for the webapp.
+ */
+ public String getVersion() {
+ return this.version;
+ }
+
+
+ /**
+ * Set the Servlet API version defined for the webapp.
+ *
+ * @param version The version
+ */
+ public void setVersion(String version) {
+ String oldVersion = this.version;
+ this.version = version;
+ support.firePropertyChange("version", oldVersion, version);
+ }
+
+
+ /**
* Return the reloadable flag for this web application.
*/
public boolean getReloadable() {
@@ -2284,11 +2310,11 @@
*/
public void addJspPropertyGroup(JspPropertyGroup propertyGroup) {
// Add any JSP mapping specified, as it needs to be mapped to the JSP Servlet
- String[] urlPatterns = propertyGroup.getUrlPatterns();
- for (int i = 0; i < urlPatterns.length; i++) {
- addJspMapping(urlPatterns[i]);
+ ArrayList<String> urlPatterns = propertyGroup.getUrlPatterns();
+ for (int i = 0; i < urlPatterns.size(); i++) {
+ addJspMapping(urlPatterns.get(i));
// Split off the groups to individual mappings
- jspPropertyGroups.put(urlPatterns[i], propertyGroup);
+ jspPropertyGroups.put(urlPatterns.get(i), propertyGroup);
}
}
@@ -4809,12 +4835,12 @@
*/
protected void postContextAttributes() {
ServletContext context = getServletContext();
+ context.setAttribute(Globals.SERVLET_VERSION, version);
context.setAttribute(Globals.RESOURCES_ATTR, getResources());
context.setAttribute(Globals.WELCOME_FILES_ATTR, welcomeFiles);
// Jasper attributes
context.setAttribute(Globals.JSP_PROPERTY_GROUPS, jspPropertyGroups);
context.setAttribute(Globals.JSP_TAG_LIBRARIES, jspTagLibraries);
- context.setAttribute(Globals.JSP_TAG_LIBRARIES_LOCATION, taglibs);
// Instance manager (also used by Jasper)
context.setAttribute(InstanceManager.class.getName(), instanceManager);
}
Modified: trunk/java/org/apache/catalina/startup/WebRuleSet.java
===================================================================
--- trunk/java/org/apache/catalina/startup/WebRuleSet.java 2009-06-06 22:18:10 UTC (rev 1087)
+++ trunk/java/org/apache/catalina/startup/WebRuleSet.java 2009-06-06 22:18:39 UTC (rev 1088)
@@ -946,6 +946,30 @@
}
/**
+ * A Rule that sets the version field on the context.
+ */
+final class VersionRule extends Rule {
+
+ public VersionRule() {
+ }
+
+ public void begin(String namespace, String name, Attributes attributes)
+ throws Exception {
+ Context context = (Context) digester.peek(digester.getCount() - 1);
+ String value = attributes.getValue("version");
+ if (value != null) {
+ context.setVersion(value);
+ }
+ if (digester.getLogger().isDebugEnabled()) {
+ digester.getLogger().debug
+ (context.getClass().getName() + ".setIgnoreAnnotations( " +
+ context.getIgnoreAnnotations() + ")");
+ }
+ }
+
+}
+
+/**
* A Rule that sets soap headers on the ContextHandler.
*
*/
15 years, 6 months
JBossWeb SVN: r1087 - trunk/java/org/apache/catalina/deploy.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-06-06 18:18:10 -0400 (Sat, 06 Jun 2009)
New Revision: 1087
Modified:
trunk/java/org/apache/catalina/deploy/JspPropertyGroup.java
Log:
- Redo in a more Jasper friendly way.
Modified: trunk/java/org/apache/catalina/deploy/JspPropertyGroup.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/JspPropertyGroup.java 2009-06-06 12:03:23 UTC (rev 1086)
+++ trunk/java/org/apache/catalina/deploy/JspPropertyGroup.java 2009-06-06 22:18:10 UTC (rev 1087)
@@ -28,90 +28,90 @@
public class JspPropertyGroup implements Serializable {
protected ArrayList<String> urlPatterns = new ArrayList<String>();
- protected boolean elIgnored = false;
+ protected String elIgnored = null;
protected String pageEncoding = null;
- protected boolean scriptingInvalid = false;
- protected boolean isXml = false;
+ protected String scriptingInvalid = null;
+ protected String isXml = null;
protected ArrayList<String> includePreludes = new ArrayList<String>();
protected ArrayList<String> includeCodas = new ArrayList<String>();
- protected boolean deferredSyntaxAllowedAsLiteral = false;
- protected boolean trimDirectiveWhitespaces = false;
+ protected String deferredSyntaxAllowedAsLiteral = null;
+ protected String trimDirectiveWhitespaces = null;
protected String defaultContentType = null;
protected String buffer = null;
- protected boolean errorOnUndeclaredNamespace = false;
+ protected String errorOnUndeclaredNamespace = null;
- public String[] getUrlPatterns() {
- return urlPatterns.toArray(new String[0]);
- }
public void addUrlPattern(String urlPattern) {
urlPatterns.add(urlPattern);
}
- public boolean isElIgnored() {
- return elIgnored;
- }
- public void setElIgnored(boolean elIgnored) {
- this.elIgnored = elIgnored;
- }
public String getPageEncoding() {
return pageEncoding;
}
public void setPageEncoding(String pageEncoding) {
this.pageEncoding = pageEncoding;
}
- public boolean isScriptingInvalid() {
+ public void addIncludePrelude(String includePrelude) {
+ includePreludes.add(includePrelude);
+ }
+ public void addIncludeCoda(String includeCoda) {
+ includeCodas.add(includeCoda);
+ }
+ public String getDefaultContentType() {
+ return defaultContentType;
+ }
+ public void setDefaultContentType(String defaultContentType) {
+ this.defaultContentType = defaultContentType;
+ }
+ public String getBuffer() {
+ return buffer;
+ }
+ public void setBuffer(String buffer) {
+ this.buffer = buffer;
+ }
+ public String getElIgnored() {
+ return elIgnored;
+ }
+ public void setElIgnored(String elIgnored) {
+ this.elIgnored = elIgnored;
+ }
+ public String getScriptingInvalid() {
return scriptingInvalid;
}
- public void setScriptingInvalid(boolean scriptingInvalid) {
+ public void setScriptingInvalid(String scriptingInvalid) {
this.scriptingInvalid = scriptingInvalid;
}
- public boolean isXml() {
+ public String getIsXml() {
return isXml;
}
- public void setXml(boolean isXml) {
+ public void setIsXml(String isXml) {
this.isXml = isXml;
}
- public String[] getIncludePreludes() {
- return includePreludes.toArray(new String[0]);
- }
- public void addIncludePrelude(String includePrelude) {
- includePreludes.add(includePrelude);
- }
- public String[] getIncludeCodas() {
- return includeCodas.toArray(new String[0]);
- }
- public void addIncludeCoda(String includeCoda) {
- includeCodas.add(includeCoda);
- }
- public boolean isDeferredSyntaxAllowedAsLiteral() {
+ public String getDeferredSyntaxAllowedAsLiteral() {
return deferredSyntaxAllowedAsLiteral;
}
public void setDeferredSyntaxAllowedAsLiteral(
- boolean deferredSyntaxAllowedAsLiteral) {
+ String deferredSyntaxAllowedAsLiteral) {
this.deferredSyntaxAllowedAsLiteral = deferredSyntaxAllowedAsLiteral;
}
- public boolean isTrimDirectiveWhitespaces() {
+ public String getTrimDirectiveWhitespaces() {
return trimDirectiveWhitespaces;
}
- public void setTrimDirectiveWhitespaces(boolean trimDirectiveWhitespaces) {
+ public void setTrimDirectiveWhitespaces(String trimDirectiveWhitespaces) {
this.trimDirectiveWhitespaces = trimDirectiveWhitespaces;
}
- public String getDefaultContentType() {
- return defaultContentType;
+ public String getErrorOnUndeclaredNamespace() {
+ return errorOnUndeclaredNamespace;
}
- public void setDefaultContentType(String defaultContentType) {
- this.defaultContentType = defaultContentType;
+ public void setErrorOnUndeclaredNamespace(String errorOnUndeclaredNamespace) {
+ this.errorOnUndeclaredNamespace = errorOnUndeclaredNamespace;
}
- public String getBuffer() {
- return buffer;
+ public ArrayList<String> getUrlPatterns() {
+ return urlPatterns;
}
- public void setBuffer(String buffer) {
- this.buffer = buffer;
+ public ArrayList<String> getIncludePreludes() {
+ return includePreludes;
}
- public boolean isErrorOnUndeclaredNamespace() {
- return errorOnUndeclaredNamespace;
+ public ArrayList<String> getIncludeCodas() {
+ return includeCodas;
}
- public void setErrorOnUndeclaredNamespace(boolean errorOnUndeclaredNamespace) {
- this.errorOnUndeclaredNamespace = errorOnUndeclaredNamespace;
- }
}
15 years, 6 months
JBossWeb SVN: r1086 - trunk/java/org/apache/jasper/compiler.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-06-06 08:03:23 -0400 (Sat, 06 Jun 2009)
New Revision: 1086
Modified:
trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
Log:
- Fix non existent TLD.
Modified: trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java 2009-06-06 10:19:15 UTC (rev 1085)
+++ trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java 2009-06-06 12:03:23 UTC (rev 1086)
@@ -141,11 +141,14 @@
this.err = err;
URL jarFileUrl = null;
- if (location[0].endsWith(".jar")) {
+ if (location == null) {
+ err.jspError("jsp.error.file.not.found", uriIn);
+ }
+ if (location[0] != null && location[0].endsWith(".jar")) {
try {
jarFileUrl = new URL("jar:file:" + location[0] + "!/");
} catch (MalformedURLException ex) {
- err.jspError("jsp.error.file.not.found", location[0]);
+ err.jspError("jsp.error.file.not.found", uriIn);
}
}
15 years, 6 months
JBossWeb SVN: r1085 - in trunk/java/org/apache: jasper and 1 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-06-06 06:19:15 -0400 (Sat, 06 Jun 2009)
New Revision: 1085
Modified:
trunk/java/org/apache/catalina/core/StandardContext.java
trunk/java/org/apache/jasper/JspCompilationContext.java
trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
Log:
- Oops: that shiny jar repository should be started.
- Comment out the debug.
- Fix URL.
Modified: trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2009-06-06 00:41:19 UTC (rev 1084)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2009-06-06 10:19:15 UTC (rev 1085)
@@ -2304,7 +2304,7 @@
for (int i = 0; i < listeners.length; i++) {
addApplicationListener(listeners[i]);
}
- System.out.println("Add TLD for URI: " + tagLibraryInfo.getUri() + " " + tagLibraryInfo);
+ //System.out.println("Add TLD for URI: " + tagLibraryInfo.getUri() + " " + tagLibraryInfo);
jspTagLibraries.put(tagLibraryInfo.getUri(), tagLibraryInfo);
}
@@ -2316,7 +2316,7 @@
* @param tagLibrayInfo the tag library info that will be added
*/
public void addJspTagLibrary(String uri, TagLibraryInfo tagLibraryInfo) {
- System.out.println("Add TLD for implicit URI: " + uri + " " + tagLibraryInfo);
+ //System.out.println("Add TLD for implicit URI: " + uri + " " + tagLibraryInfo);
jspTagLibraries.put(uri, tagLibraryInfo);
}
@@ -4064,6 +4064,8 @@
started = true;
// Start our subordinate components, if any
+ if ((jarRepository != null) && (jarRepository instanceof Lifecycle))
+ ((Lifecycle) jarRepository).start();
if ((loader != null) && (loader instanceof Lifecycle))
((Lifecycle) loader).start();
Modified: trunk/java/org/apache/jasper/JspCompilationContext.java
===================================================================
--- trunk/java/org/apache/jasper/JspCompilationContext.java 2009-06-06 00:41:19 UTC (rev 1084)
+++ trunk/java/org/apache/jasper/JspCompilationContext.java 2009-06-06 10:19:15 UTC (rev 1085)
@@ -556,14 +556,7 @@
* 'exposed' in the web application.
*/
public String[] getTldLocation(String uri) throws JasperException {
- System.out.print("Look for: " + uri + " TLDs list: ");
- Iterator<String> keys = jspTagLibraries.keySet().iterator();
- while (keys.hasNext()) {
- System.out.print(keys.next() + ", ");
- }
- System.out.println();
org.apache.catalina.deploy.jsp.TagLibraryInfo tagLibraryInfo = jspTagLibraries.get(uri);
- System.out.println("Result: " + tagLibraryInfo);
if (tagLibraryInfo == null) {
return null;
} else {
@@ -577,9 +570,12 @@
return location;
}
/*
- String[] location =
- getOptions().getTldLocationsCache().getLocation(uri);
- return location;
+ System.out.print("Look for: " + uri + " TLDs list: ");
+ Iterator<String> keys = jspTagLibraries.keySet().iterator();
+ while (keys.hasNext()) {
+ System.out.print(keys.next() + ", ");
+ }
+ System.out.println();
*/
}
Modified: trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java 2009-06-06 00:41:19 UTC (rev 1084)
+++ trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java 2009-06-06 10:19:15 UTC (rev 1085)
@@ -143,7 +143,7 @@
URL jarFileUrl = null;
if (location[0].endsWith(".jar")) {
try {
- jarFileUrl = new URL("jar:" + location[0] + "!/");
+ jarFileUrl = new URL("jar:file:" + location[0] + "!/");
} catch (MalformedURLException ex) {
err.jspError("jsp.error.file.not.found", location[0]);
}
15 years, 6 months
JBossWeb SVN: r1084 - in trunk: java/org/apache/jasper and 1 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-06-05 20:41:19 -0400 (Fri, 05 Jun 2009)
New Revision: 1084
Modified:
trunk/PATCHES.txt
trunk/java/org/apache/jasper/JspCompilationContext.java
trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
Log:
- Generate tagext objects from the Catalina metadata, rather than parse TLDs in Jasper. With debug, and does not fully work yet.
Modified: trunk/PATCHES.txt
===================================================================
--- trunk/PATCHES.txt 2009-06-06 00:40:15 UTC (rev 1083)
+++ trunk/PATCHES.txt 2009-06-06 00:41:19 UTC (rev 1084)
@@ -74,3 +74,9 @@
781036
Some configBase creation flag
+
+781779
+Useless syncing
+
+782000 782005 782007 782010 782013 782032
+Changes to APR init
Modified: trunk/java/org/apache/jasper/JspCompilationContext.java
===================================================================
--- trunk/java/org/apache/jasper/JspCompilationContext.java 2009-06-06 00:40:15 UTC (rev 1083)
+++ trunk/java/org/apache/jasper/JspCompilationContext.java 2009-06-06 00:41:19 UTC (rev 1084)
@@ -23,12 +23,14 @@
import java.net.URL;
import java.net.URLClassLoader;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.servlet.ServletContext;
import javax.servlet.jsp.tagext.TagInfo;
+import org.apache.catalina.Globals;
import org.apache.jasper.compiler.Compiler;
import org.apache.jasper.compiler.JspRuntimeContext;
import org.apache.jasper.compiler.JspUtil;
@@ -92,6 +94,8 @@
protected TagInfo tagInfo;
protected URL tagFileJarUrl;
+ protected HashMap<String, org.apache.catalina.deploy.jsp.TagLibraryInfo> jspTagLibraries = null;
+
// jspURI _must_ be relative to the context
public JspCompilationContext(String jspUri,
boolean isErrPage,
@@ -122,6 +126,12 @@
this.rctxt = rctxt;
this.tagFileJarUrls = new HashMap<String, URL>();
this.basePackageName = Constants.JSP_PACKAGE_NAME;
+ jspTagLibraries = (HashMap<String, org.apache.catalina.deploy.jsp.TagLibraryInfo>)
+ context.getAttribute(Globals.JSP_TAG_LIBRARIES);
+ if (jspTagLibraries == null) {
+ // FIXME: error message, Jasper needs TLD data
+ throw new IllegalStateException();
+ }
}
public JspCompilationContext(String tagfile,
@@ -546,9 +556,31 @@
* 'exposed' in the web application.
*/
public String[] getTldLocation(String uri) throws JasperException {
+ System.out.print("Look for: " + uri + " TLDs list: ");
+ Iterator<String> keys = jspTagLibraries.keySet().iterator();
+ while (keys.hasNext()) {
+ System.out.print(keys.next() + ", ");
+ }
+ System.out.println();
+ org.apache.catalina.deploy.jsp.TagLibraryInfo tagLibraryInfo = jspTagLibraries.get(uri);
+ System.out.println("Result: " + tagLibraryInfo);
+ if (tagLibraryInfo == null) {
+ return null;
+ } else {
+ String[] location = new String[2];
+ if (tagLibraryInfo.getLocation() == null) {
+ location[0] = tagLibraryInfo.getPath();
+ } else {
+ location[0] = tagLibraryInfo.getLocation();
+ location[1] = tagLibraryInfo.getPath();
+ }
+ return location;
+ }
+ /*
String[] location =
getOptions().getTldLocationsCache().getLocation(uri);
return location;
+ */
}
/**
Modified: trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java 2009-06-06 00:40:15 UTC (rev 1083)
+++ trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java 2009-06-06 00:41:19 UTC (rev 1084)
@@ -22,16 +22,16 @@
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.net.JarURLConnection;
+import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
-import java.util.jar.JarFile;
-import java.util.zip.ZipEntry;
import javax.servlet.jsp.tagext.FunctionInfo;
import javax.servlet.jsp.tagext.PageData;
@@ -45,12 +45,12 @@
import javax.servlet.jsp.tagext.ValidationMessage;
import javax.servlet.jsp.tagext.VariableInfo;
+import org.apache.catalina.Globals;
import org.apache.jasper.JasperException;
import org.apache.jasper.JspCompilationContext;
import org.apache.jasper.xmlparser.ParserUtils;
import org.apache.jasper.xmlparser.TreeNode;
import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
/**
* Implementation of the TagLibraryInfo class from the JSP spec.
@@ -139,65 +139,64 @@
this.parserController = pc;
this.pi = pi;
this.err = err;
- InputStream in = null;
- JarFile jarFile = null;
-
- if (location == null) {
- // The URI points to the TLD itself or to a JAR file in which the
- // TLD is stored
- location = generateTLDLocation(uri, ctxt);
+
+ URL jarFileUrl = null;
+ if (location[0].endsWith(".jar")) {
+ try {
+ jarFileUrl = new URL("jar:" + location[0] + "!/");
+ } catch (MalformedURLException ex) {
+ err.jspError("jsp.error.file.not.found", location[0]);
+ }
}
+
+ org.apache.catalina.deploy.jsp.TagLibraryInfo tagLibraryInfo =
+ ((HashMap<String, org.apache.catalina.deploy.jsp.TagLibraryInfo>)
+ ctxt.getServletContext().getAttribute(Globals.JSP_TAG_LIBRARIES)).get(uriIn);
- try {
- if (!location[0].endsWith("jar")) {
- // Location points to TLD file
- try {
- in = getResourceAsStream(location[0]);
- if (in == null) {
- throw new FileNotFoundException(location[0]);
- }
- } catch (FileNotFoundException ex) {
- err.jspError("jsp.error.file.not.found", location[0]);
- }
+ ArrayList<TagInfo> tagInfos = new ArrayList<TagInfo>();
+ ArrayList<TagFileInfo> tagFileInfos = new ArrayList<TagFileInfo>();
+ HashMap<String, FunctionInfo> functionInfos = new HashMap<String, FunctionInfo>();
- parseTLD(ctxt, location[0], in, null);
- // Add TLD to dependency list
- PageInfo pageInfo = ctxt.createCompiler().getPageInfo();
- if (pageInfo != null) {
- pageInfo.addDependant(location[0]);
- }
- } else {
- // Tag library is packaged in JAR file
- try {
- URL jarFileUrl = new URL("jar:" + location[0] + "!/");
- JarURLConnection conn = (JarURLConnection) jarFileUrl
- .openConnection();
- conn.setUseCaches(false);
- conn.connect();
- jarFile = conn.getJarFile();
- ZipEntry jarEntry = jarFile.getEntry(location[1]);
- in = jarFile.getInputStream(jarEntry);
- parseTLD(ctxt, location[0], in, jarFileUrl);
- } catch (Exception ex) {
- err.jspError("jsp.error.tld.unable_to_read", location[0],
- location[1], ex.toString());
- }
+ this.jspversion = tagLibraryInfo.getJspversion();
+ this.tlibversion = tagLibraryInfo.getTlibversion();
+ this.shortname = tagLibraryInfo.getShortname();
+ this.urn = tagLibraryInfo.getUri();
+ this.info = tagLibraryInfo.getInfo();
+ if (tagLibraryInfo.getValidator() != null) {
+ this.tagLibraryValidator = createValidator(tagLibraryInfo);
+ }
+ org.apache.catalina.deploy.jsp.TagInfo tagInfosArray[] = tagLibraryInfo.getTags();
+ for (int i = 0; i < tagInfosArray.length; i++) {
+ TagInfo tagInfo = createTagInfo(tagInfosArray[i]);
+ tagInfos.add(tagInfo);
+ }
+ org.apache.catalina.deploy.jsp.TagFileInfo tagFileInfosArray[] = tagLibraryInfo.getTagFileInfos();
+ for (int i = 0; i < tagFileInfosArray.length; i++) {
+ TagFileInfo tagFileInfo = createTagFileInfo(tagFileInfosArray[i], jarFileUrl);
+ tagFileInfos.add(tagFileInfo);
+ }
+ org.apache.catalina.deploy.jsp.FunctionInfo functionInfosArray[] = tagLibraryInfo.getFunctionInfos();
+ for (int i = 0; i < functionInfosArray.length; i++) {
+ FunctionInfo functionInfo = createFunctionInfo(functionInfosArray[i]);
+ if (functionInfos.containsKey(functionInfo.getName())) {
+ err.jspError("jsp.error.tld.fn.duplicate.name", functionInfo.getName(),
+ uri);
}
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (Throwable t) {
- }
- }
- if (jarFile != null) {
- try {
- jarFile.close();
- } catch (Throwable t) {
- }
- }
+ functionInfos.put(functionInfo.getName(), functionInfo);
}
+
+ if (tlibversion == null) {
+ err.jspError("jsp.error.tld.mandatory.element.missing",
+ "tlib-version");
+ }
+ if (jspversion == null) {
+ err.jspError("jsp.error.tld.mandatory.element.missing",
+ "jsp-version");
+ }
+ this.tags = tagInfos.toArray(new TagInfo[0]);
+ this.tagFiles = tagFileInfos.toArray(new TagFileInfo[0]);
+ this.functions = functionInfos.values().toArray(new FunctionInfo[0]);
}
public TagLibraryInfo[] getTagLibraryInfos() {
@@ -205,6 +204,150 @@
return (TagLibraryInfo[]) coll.toArray(new TagLibraryInfo[0]);
}
+ protected TagInfo createTagInfo(org.apache.catalina.deploy.jsp.TagInfo tagInfo)
+ throws JasperException {
+
+ ArrayList<TagAttributeInfo> attributeInfos = new ArrayList<TagAttributeInfo>();
+ ArrayList<TagVariableInfo> variableInfos = new ArrayList<TagVariableInfo>();
+
+ org.apache.catalina.deploy.jsp.TagAttributeInfo attributeInfosArray[] = tagInfo.getTagAttributeInfos();
+ for (int i = 0; i < attributeInfosArray.length; i++) {
+ TagAttributeInfo attributeInfo = createTagAttributeInfo(attributeInfosArray[i]);
+ attributeInfos.add(attributeInfo);
+ }
+
+ org.apache.catalina.deploy.jsp.TagVariableInfo variableInfosArray[] = tagInfo.getTagVariableInfos();
+ for (int i = 0; i < variableInfosArray.length; i++) {
+ TagVariableInfo variableInfo = createTagVariableInfo(variableInfosArray[i]);
+ variableInfos.add(variableInfo);
+ }
+
+ TagExtraInfo tei = null;
+ String teiClassName = tagInfo.getTagExtraInfo();
+ if (teiClassName != null && !teiClassName.equals("")) {
+ try {
+ Class teiClass = ctxt.getClassLoader().loadClass(teiClassName);
+ tei = (TagExtraInfo) teiClass.newInstance();
+ } catch (Exception e) {
+ err.jspError("jsp.error.teiclass.instantiation", teiClassName,
+ e);
+ }
+ }
+
+ return new TagInfo(tagInfo.getTagName(), tagInfo.getTagClassName(), tagInfo.getBodyContent(),
+ tagInfo.getInfoString(), this, tei, attributeInfos.toArray(new TagAttributeInfo[0]),
+ tagInfo.getDisplayName(), tagInfo.getSmallIcon(), tagInfo.getLargeIcon(),
+ variableInfos.toArray(new TagVariableInfo[0]), tagInfo.isDynamicAttributes());
+ }
+
+ protected TagAttributeInfo createTagAttributeInfo(org.apache.catalina.deploy.jsp.TagAttributeInfo attributeInfo) {
+
+ String type = attributeInfo.getType();
+ String expectedType = attributeInfo.getExpectedTypeName();
+ String methodSignature = attributeInfo.getMethodSignature();
+ boolean rtexprvalue = attributeInfo.isReqTime();
+
+ if (type != null) {
+ if ("1.2".equals(jspversion)
+ && (type.equals("Boolean") || type.equals("Byte")
+ || type.equals("Character")
+ || type.equals("Double")
+ || type.equals("Float")
+ || type.equals("Integer")
+ || type.equals("Long") || type.equals("Object")
+ || type.equals("Short") || type
+ .equals("String"))) {
+ type = "java.lang." + type;
+ }
+ }
+
+ if (attributeInfo.isDeferredValue()) {
+ type = "javax.el.ValueExpression";
+ if (expectedType != null) {
+ expectedType = expectedType.trim();
+ } else {
+ expectedType = "java.lang.Object";
+ }
+ }
+
+ if (attributeInfo.isDeferredMethod()) {
+ type = "javax.el.MethodExpression";
+ if (methodSignature != null) {
+ methodSignature = methodSignature.trim();
+ } else {
+ methodSignature = "java.lang.Object method()";
+ }
+ }
+
+ if (attributeInfo.isFragment()) {
+ /*
+ * According to JSP.C-3 ("TLD Schema Element Structure - tag"),
+ * 'type' and 'rtexprvalue' must not be specified if 'fragment' has
+ * been specified (this will be enforced by validating parser).
+ * Also, if 'fragment' is TRUE, 'type' is fixed at
+ * javax.servlet.jsp.tagext.JspFragment, and 'rtexprvalue' is fixed
+ * at true. See also JSP.8.5.2.
+ */
+ type = "javax.servlet.jsp.tagext.JspFragment";
+ rtexprvalue = true;
+ }
+
+ if (!rtexprvalue && type == null) {
+ // According to JSP spec, for static values (those determined at
+ // translation time) the type is fixed at java.lang.String.
+ type = "java.lang.String";
+ }
+
+ return new TagAttributeInfo(attributeInfo.getName(), attributeInfo.isRequired(),
+ type, rtexprvalue, attributeInfo.isFragment(), attributeInfo.getDescription(),
+ attributeInfo.isDeferredValue(), attributeInfo.isDeferredMethod(), expectedType,
+ methodSignature);
+ }
+
+ protected TagVariableInfo createTagVariableInfo(org.apache.catalina.deploy.jsp.TagVariableInfo variableInfo) {
+ int scope = VariableInfo.NESTED;
+ String s = variableInfo.getScope();
+ if (s != null) {
+ if ("NESTED".equals(s)) {
+ scope = VariableInfo.NESTED;
+ } else if ("AT_BEGIN".equals(s)) {
+ scope = VariableInfo.AT_BEGIN;
+ } else if ("AT_END".equals(s)) {
+ scope = VariableInfo.AT_END;
+ }
+ }
+ String className = variableInfo.getClassName();
+ if (className != null) {
+ className = "java.lang.String";
+ }
+ return new TagVariableInfo(variableInfo.getNameGiven(), variableInfo.getNameFromAttribute(),
+ className, variableInfo.isDeclare(), scope);
+ }
+
+ protected TagFileInfo createTagFileInfo(org.apache.catalina.deploy.jsp.TagFileInfo tagFileInfo, URL jarFileUrl)
+ throws JasperException {
+ String name = tagFileInfo.getName();
+ String path = tagFileInfo.getPath();
+ if (path.startsWith("/META-INF/tags")) {
+ // Tag file packaged in JAR
+ // See https://issues.apache.org/bugzilla/show_bug.cgi?id=46471
+ // This needs to be removed once all the broken code that depends on
+ // it has been removed
+ ctxt.setTagFileJarUrl(path, jarFileUrl);
+ } else if (!path.startsWith("/WEB-INF/tags")) {
+ err.jspError("jsp.error.tagfile.illegalPath", path);
+ }
+ TagInfo tagInfo = TagFileProcessor.parseTagFileDirectives(
+ parserController, name, path, jarFileUrl, this);
+ return new TagFileInfo(name, path, tagInfo);
+ }
+
+ protected FunctionInfo createFunctionInfo(org.apache.catalina.deploy.jsp.FunctionInfo functionInfo) {
+ return new FunctionInfo(functionInfo.getName(),
+ functionInfo.getFunctionClass(), functionInfo.getFunctionSignature());
+ }
+
+
/*
* @param ctxt The JSP compilation context @param uri The TLD's uri @param
* in The TLD's input stream @param jarFileUrl The JAR file containing the
@@ -336,6 +479,46 @@
return location;
}
+ private TagLibraryValidator createValidator(TreeNode elem)
+ throws JasperException {
+
+ String validatorClass = null;
+ Map initParams = new Hashtable();
+
+ Iterator list = elem.findChildren();
+ while (list.hasNext()) {
+ TreeNode element = (TreeNode) list.next();
+ String tname = element.getName();
+ if ("validator-class".equals(tname))
+ validatorClass = element.getBody();
+ else if ("init-param".equals(tname)) {
+ String[] initParam = createInitParam(element);
+ initParams.put(initParam[0], initParam[1]);
+ } else if ("description".equals(tname) || // Ignored elements
+ false) {
+ } else {
+ log.warn(Localizer.getMessage(
+ "jsp.warning.unknown.element.in.validator", tname));
+ }
+ }
+
+ TagLibraryValidator tlv = null;
+ if (validatorClass != null && !validatorClass.equals("")) {
+ try {
+ Class tlvClass = ctxt.getClassLoader()
+ .loadClass(validatorClass);
+ tlv = (TagLibraryValidator) tlvClass.newInstance();
+ } catch (Exception e) {
+ err.jspError("jsp.error.tlvclass.instantiation",
+ validatorClass, e);
+ }
+ }
+ if (tlv != null) {
+ tlv.setInitParameters(initParams);
+ }
+ return tlv;
+ }
+
private TagInfo createTagInfo(TreeNode elem, String jspVersion)
throws JasperException {
@@ -624,29 +807,12 @@
declare, scope);
}
- private TagLibraryValidator createValidator(TreeNode elem)
+ private TagLibraryValidator createValidator(org.apache.catalina.deploy.jsp.TagLibraryInfo tagLibraryInfo)
throws JasperException {
+ org.apache.catalina.deploy.jsp.TagLibraryValidatorInfo tlvInfo = tagLibraryInfo.getValidator();
+ String validatorClass = tlvInfo.getValidatorClass();
+ Map<String, Object> initParams = tlvInfo.getInitParams();
- String validatorClass = null;
- Map initParams = new Hashtable();
-
- Iterator list = elem.findChildren();
- while (list.hasNext()) {
- TreeNode element = (TreeNode) list.next();
- String tname = element.getName();
- if ("validator-class".equals(tname))
- validatorClass = element.getBody();
- else if ("init-param".equals(tname)) {
- String[] initParam = createInitParam(element);
- initParams.put(initParam[0], initParam[1]);
- } else if ("description".equals(tname) || // Ignored elements
- false) {
- } else {
- log.warn(Localizer.getMessage(
- "jsp.warning.unknown.element.in.validator", tname));
- }
- }
-
TagLibraryValidator tlv = null;
if (validatorClass != null && !validatorClass.equals("")) {
try {
15 years, 6 months
JBossWeb SVN: r1083 - in trunk/java/org/apache/catalina: core and 2 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-06-05 20:40:15 -0400 (Fri, 05 Jun 2009)
New Revision: 1083
Modified:
trunk/java/org/apache/catalina/Context.java
trunk/java/org/apache/catalina/core/StandardContext.java
trunk/java/org/apache/catalina/deploy/jsp/FunctionInfo.java
trunk/java/org/apache/catalina/deploy/jsp/TagVariableInfo.java
trunk/java/org/apache/catalina/startup/ContextConfig.java
trunk/java/org/apache/catalina/startup/TldRuleSet.java
Log:
- I had forgotten about the implicit URI details ...
- Add forgotten function parsing. Oops.
Modified: trunk/java/org/apache/catalina/Context.java
===================================================================
--- trunk/java/org/apache/catalina/Context.java 2009-06-04 21:54:35 UTC (rev 1082)
+++ trunk/java/org/apache/catalina/Context.java 2009-06-06 00:40:15 UTC (rev 1083)
@@ -598,6 +598,14 @@
/**
+ * Add the given JSP tag library metadata.
+ *
+ * @param tagLibraryInfo the tag library info that will be added
+ */
+ public void addJspTagLibrary(String uri, TagLibraryInfo tagLibraryInfo);
+
+
+ /**
* Add a Locale Encoding Mapping (see Sec 5.4 of Servlet spec 2.4)
*
* @param locale locale to map an encoding for
Modified: trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2009-06-04 21:54:35 UTC (rev 1082)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2009-06-06 00:40:15 UTC (rev 1083)
@@ -2304,11 +2304,24 @@
for (int i = 0; i < listeners.length; i++) {
addApplicationListener(listeners[i]);
}
+ System.out.println("Add TLD for URI: " + tagLibraryInfo.getUri() + " " + tagLibraryInfo);
jspTagLibraries.put(tagLibraryInfo.getUri(), tagLibraryInfo);
}
/**
+ * Add the given JSP tag library metadata with a specified mapping.
+ *
+ * @param uri the tag library URI
+ * @param tagLibrayInfo the tag library info that will be added
+ */
+ public void addJspTagLibrary(String uri, TagLibraryInfo tagLibraryInfo) {
+ System.out.println("Add TLD for implicit URI: " + uri + " " + tagLibraryInfo);
+ jspTagLibraries.put(uri, tagLibraryInfo);
+ }
+
+
+ /**
* Add a Locale Encoding Mapping (see Sec 5.4 of Servlet spec 2.4)
*
* @param locale locale to map an encoding for
Modified: trunk/java/org/apache/catalina/deploy/jsp/FunctionInfo.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/jsp/FunctionInfo.java 2009-06-04 21:54:35 UTC (rev 1082)
+++ trunk/java/org/apache/catalina/deploy/jsp/FunctionInfo.java 2009-06-06 00:40:15 UTC (rev 1083)
@@ -19,6 +19,7 @@
public class FunctionInfo {
+ protected String description;
protected String name;
protected String functionClass;
protected String functionSignature;
@@ -41,5 +42,11 @@
public void setFunctionSignature(String functionSignature) {
this.functionSignature = functionSignature;
}
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
}
Modified: trunk/java/org/apache/catalina/deploy/jsp/TagVariableInfo.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/jsp/TagVariableInfo.java 2009-06-04 21:54:35 UTC (rev 1082)
+++ trunk/java/org/apache/catalina/deploy/jsp/TagVariableInfo.java 2009-06-06 00:40:15 UTC (rev 1083)
@@ -25,8 +25,8 @@
protected String nameGiven; // <name-given>
protected String nameFromAttribute; // <name-from-attribute>
protected String className; // <class>
- protected boolean declare; // <declare>
- protected int scope; // <scope>
+ protected boolean declare = true; // <declare>
+ protected String scope; // <scope>
public String getNameGiven() {
return nameGiven;
@@ -52,10 +52,10 @@
public void setDeclare(boolean declare) {
this.declare = declare;
}
- public int getScope() {
+ public String getScope() {
return scope;
}
- public void setScope(int scope) {
+ public void setScope(String scope) {
this.scope = scope;
}
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-06-04 21:54:35 UTC (rev 1082)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-06-06 00:40:15 UTC (rev 1083)
@@ -598,17 +598,9 @@
*/
protected void applicationTldConfig() {
- // Add all TLDs from explicit web config
Map<String, Set<String>> TLDs = getTLDs();
Set<String> warTLDs = TLDs.get("");
- String taglibs[] = context.findTaglibs();
- for (int i = 0; i < taglibs.length; i++) {
- String resourcePath = context.findTaglib(taglibs[i]);
- if (!resourcePath.startsWith("/")) {
- resourcePath = "/WEB-INF/" + resourcePath;
- }
- warTLDs.add(resourcePath);
- }
+ ArrayList<TagLibraryInfo> tagLibraries = new ArrayList<TagLibraryInfo>();
// Parse all TLDs from the WAR
Iterator<String> warTLDsIterator = warTLDs.iterator();
@@ -631,7 +623,9 @@
}
tagLibraryInfo.setLocation("");
tagLibraryInfo.setPath(tldPath);
+ tagLibraries.add(tagLibraryInfo);
context.addJspTagLibrary(tagLibraryInfo);
+ context.addJspTagLibrary(tldPath, tagLibraryInfo);
}
}
} catch (Exception e) {
@@ -681,7 +675,11 @@
}
tagLibraryInfo.setLocation(jarPath);
tagLibraryInfo.setPath(tldPath);
+ tagLibraries.add(tagLibraryInfo);
context.addJspTagLibrary(tagLibraryInfo);
+ if (tldPath.equals("META-INF/taglib.tld")) {
+ context.addJspTagLibrary(jarPath, tagLibraryInfo);
+ }
}
}
} catch (Exception e) {
@@ -698,6 +696,27 @@
}
}
}
+
+ // Add additional TLDs URIs from explicit web config
+ String taglibs[] = context.findTaglibs();
+ for (int i = 0; i < taglibs.length; i++) {
+ String uri = taglibs[i];
+ String path = context.findTaglib(taglibs[i]);
+ String location = "";
+ if (path.indexOf(':') == -1 && !path.startsWith("/")) {
+ path = "/WEB-INF/" + path;
+ }
+ if (path.endsWith(".jar")) {
+ location = path;
+ path = "META-INF/taglib.tld";
+ }
+ for (int j = 0; j < tagLibraries.size(); j++) {
+ TagLibraryInfo tagLibraryInfo = tagLibraries.get(j);
+ if (tagLibraryInfo.getLocation().equals(location) && tagLibraryInfo.getPath().equals(path)) {
+ context.addJspTagLibrary(uri, tagLibraryInfo);
+ }
+ }
+ }
}
Modified: trunk/java/org/apache/catalina/startup/TldRuleSet.java
===================================================================
--- trunk/java/org/apache/catalina/startup/TldRuleSet.java 2009-06-04 21:54:35 UTC (rev 1082)
+++ trunk/java/org/apache/catalina/startup/TldRuleSet.java 2009-06-06 00:40:15 UTC (rev 1083)
@@ -103,7 +103,7 @@
digester.addCallMethod(prefix + "taglib/short-name",
"setShortname", 0);
digester.addCallMethod(prefix + "taglib/uri",
- "setUrn", 0);
+ "setUri", 0);
digester.addCallMethod(prefix + "taglib/info",
"setInfo", 0);
digester.addCallMethod(prefix + "taglib/description",
@@ -207,6 +207,21 @@
digester.addCallMethod(prefix + "taglib/tag/attribute/deferred-value/method-signature",
"setMethodSignature", 0);
+ // tag/function element
+ digester.addObjectCreate(prefix + "taglib/function",
+ "org.apache.catalina.deploy.jsp.FunctionInfo");
+ digester.addSetNext(prefix + "taglib/function",
+ "addFunctionInfo",
+ "org.apache.catalina.deploy.jsp.FunctionInfo");
+ digester.addCallMethod(prefix + "taglib/function/name",
+ "setName", 0);
+ digester.addCallMethod(prefix + "taglib/function/description",
+ "setDescription", 0);
+ digester.addCallMethod(prefix + "taglib/function/function-class",
+ "setFunctionClass", 0);
+ digester.addCallMethod(prefix + "taglib/function/function-signature",
+ "setFunctionSignature", 0);
+
}
15 years, 6 months
JBossWeb SVN: r1082 - trunk/java/org/apache/catalina/deploy/jsp.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-06-04 17:54:35 -0400 (Thu, 04 Jun 2009)
New Revision: 1082
Modified:
trunk/java/org/apache/catalina/deploy/jsp/TagAttributeInfo.java
trunk/java/org/apache/catalina/deploy/jsp/TagLibraryInfo.java
trunk/java/org/apache/catalina/deploy/jsp/TagLibraryValidatorInfo.java
Log:
- Some defaults and type updates, as I update the Jasper code.
Modified: trunk/java/org/apache/catalina/deploy/jsp/TagAttributeInfo.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/jsp/TagAttributeInfo.java 2009-06-04 15:03:52 UTC (rev 1081)
+++ trunk/java/org/apache/catalina/deploy/jsp/TagAttributeInfo.java 2009-06-04 21:54:35 UTC (rev 1082)
@@ -20,18 +20,18 @@
public class TagAttributeInfo {
protected String name;
protected String type;
- protected boolean reqTime;
- protected boolean required;
+ protected boolean reqTime = false;
+ protected boolean required = false;
/*
* private fields for JSP 2.0
*/
- protected boolean fragment;
+ protected boolean fragment = false;
/*
* private fields for JSP 2.1
*/
protected String description;
- protected boolean deferredValue;
- protected boolean deferredMethod;
+ protected boolean deferredValue = false;
+ protected boolean deferredMethod = false;
protected String expectedTypeName;
protected String methodSignature;
Modified: trunk/java/org/apache/catalina/deploy/jsp/TagLibraryInfo.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/jsp/TagLibraryInfo.java 2009-06-04 15:03:52 UTC (rev 1081)
+++ trunk/java/org/apache/catalina/deploy/jsp/TagLibraryInfo.java 2009-06-04 21:54:35 UTC (rev 1082)
@@ -126,6 +126,13 @@
this.jspversion = jspversion;
}
+ /**
+ * For the version attribute.
+ */
+ public void setVersion(String jspversion) {
+ this.jspversion = jspversion;
+ }
+
public String getShortname() {
return shortname;
}
Modified: trunk/java/org/apache/catalina/deploy/jsp/TagLibraryValidatorInfo.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/jsp/TagLibraryValidatorInfo.java 2009-06-04 15:03:52 UTC (rev 1081)
+++ trunk/java/org/apache/catalina/deploy/jsp/TagLibraryValidatorInfo.java 2009-06-04 21:54:35 UTC (rev 1082)
@@ -23,7 +23,7 @@
public class TagLibraryValidatorInfo {
protected String validatorClass;
- protected Map<String, String> initParams = new HashMap<String, String>();
+ protected Map<String, Object> initParams = new HashMap<String, Object>();
public String getValidatorClass() {
return validatorClass;
@@ -31,10 +31,10 @@
public void setValidatorClass(String validatorClass) {
this.validatorClass = validatorClass;
}
- public void addInitParam(String name, String value) {
+ public void addInitParam(String name, Object value) {
initParams.put(name, value);
}
- public Map<String, String> getInitParams() {
+ public Map<String, Object> getInitParams() {
return initParams;
}
15 years, 6 months
JBossWeb SVN: r1081 - in branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache: catalina/core and 4 other directories.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-06-04 11:03:52 -0400 (Thu, 04 Jun 2009)
New Revision: 1081
Modified:
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/Request.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationContext.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationHttpRequest.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/servlets/WebdavServlet.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/ssi/SSIServletRequestUtil.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/util/RequestUtil.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/naming/resources/FileDirContext.java
Log:
Rollback previous commit... Nice clean up but CP...
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/Request.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/Request.java 2009-06-04 14:15:54 UTC (rev 1080)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/Request.java 2009-06-04 15:03:52 UTC (rev 1081)
@@ -67,6 +67,7 @@
import org.apache.catalina.realm.GenericPrincipal;
import org.apache.catalina.util.Enumerator;
import org.apache.catalina.util.ParameterMap;
+import org.apache.catalina.util.RequestUtil;
import org.apache.catalina.util.StringManager;
import org.apache.catalina.util.StringParser;
@@ -1268,9 +1269,10 @@
int pos = requestPath.lastIndexOf('/');
String relative = null;
if (pos >= 0) {
- relative = requestPath.substring(0, pos + 1) + path;
+ relative = RequestUtil.normalize
+ (requestPath.substring(0, pos + 1) + path);
} else {
- relative = requestPath + path;
+ relative = RequestUtil.normalize(requestPath + path);
}
return (context.getServletContext().getRequestDispatcher(relative));
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationContext.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationContext.java 2009-06-04 14:15:54 UTC (rev 1080)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationContext.java 2009-06-04 15:03:52 UTC (rev 1081)
@@ -44,7 +44,6 @@
import org.apache.catalina.Wrapper;
import org.apache.catalina.deploy.ApplicationParameter;
import org.apache.catalina.util.Enumerator;
-import org.apache.catalina.util.RequestUtil;
import org.apache.catalina.util.ResourceSet;
import org.apache.catalina.util.ServerInfo;
import org.apache.catalina.util.StringManager;
@@ -378,7 +377,7 @@
path = path.substring(0, pos);
}
- path = RequestUtil.normalize(path);
+ path = normalize(path);
if (path == null)
return (null);
@@ -460,7 +459,7 @@
throw new MalformedURLException(sm.getString("applicationContext.requestDispatcher.iae", path));
}
- path = RequestUtil.normalize(path);
+ path = normalize(path);
if (path == null)
return (null);
@@ -509,13 +508,10 @@
*/
public InputStream getResourceAsStream(String path) {
+ path = normalize(path);
if (path == null)
return (null);
- path = RequestUtil.normalize(path);
- if (path == null)
- return (null);
-
DirContext resources = context.getResources();
if (resources != null) {
try {
@@ -548,7 +544,7 @@
(sm.getString("applicationContext.resourcePaths.iae", path));
}
- path = RequestUtil.normalize(path);
+ path = normalize(path);
if (path == null)
return (null);
@@ -855,6 +851,45 @@
/**
+ * Return a context-relative path, beginning with a "/", that represents
+ * the canonical version of the specified path after ".." and "." elements
+ * are resolved out. If the specified path attempts to go outside the
+ * boundaries of the current context (i.e. too many ".." path elements
+ * are present), return <code>null</code> instead.
+ *
+ * @param path Path to be normalized
+ */
+ private String normalize(String path) {
+
+ if (path == null) {
+ return null;
+ }
+
+ String normalized = path;
+
+ // Normalize the slashes and add leading slash if necessary
+ if (normalized.indexOf('\\') >= 0)
+ normalized = normalized.replace('\\', '/');
+
+ // Resolve occurrences of "/../" in the normalized path
+ while (true) {
+ int index = normalized.indexOf("/../");
+ if (index < 0)
+ break;
+ if (index == 0)
+ return (null); // Trying to go outside our context
+ int index2 = normalized.lastIndexOf('/', index - 1);
+ normalized = normalized.substring(0, index2) +
+ normalized.substring(index + 3);
+ }
+
+ // Return the normalized path that we have completed
+ return (normalized);
+
+ }
+
+
+ /**
* Merge the context initialization parameters specified in the application
* deployment descriptor with the application parameters described in the
* server configuration, respecting the <code>override</code> property of
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationHttpRequest.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationHttpRequest.java 2009-06-04 14:15:54 UTC (rev 1080)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationHttpRequest.java 2009-06-04 15:03:52 UTC (rev 1081)
@@ -318,9 +318,10 @@
int pos = requestPath.lastIndexOf('/');
String relative = null;
if (pos >= 0) {
- relative = requestPath.substring(0, pos + 1) + path;
+ relative = RequestUtil.normalize
+ (requestPath.substring(0, pos + 1) + path);
} else {
- relative = requestPath + path;
+ relative = RequestUtil.normalize(requestPath + path);
}
return (context.getServletContext().getRequestDispatcher(relative));
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/servlets/WebdavServlet.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/servlets/WebdavServlet.java 2009-06-04 14:15:54 UTC (rev 1080)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/servlets/WebdavServlet.java 2009-06-04 15:03:52 UTC (rev 1081)
@@ -1374,6 +1374,71 @@
}
+ /**
+ * Return a context-relative path, beginning with a "/", that represents
+ * the canonical version of the specified path after ".." and "." elements
+ * are resolved out. If the specified path attempts to go outside the
+ * boundaries of the current context (i.e. too many ".." path elements
+ * are present), return <code>null</code> instead.
+ *
+ * @param path Path to be normalized
+ */
+ protected String normalize(String path) {
+
+ if (path == null)
+ return null;
+
+ // Create a place for the normalized path
+ String normalized = path;
+
+ if (normalized == null)
+ return (null);
+
+ if (normalized.equals("/."))
+ return "/";
+
+ // Normalize the slashes and add leading slash if necessary
+ if (normalized.indexOf('\\') >= 0)
+ normalized = normalized.replace('\\', '/');
+ if (!normalized.startsWith("/"))
+ normalized = "/" + normalized;
+
+ // Resolve occurrences of "//" in the normalized path
+ while (true) {
+ int index = normalized.indexOf("//");
+ if (index < 0)
+ break;
+ normalized = normalized.substring(0, index) +
+ normalized.substring(index + 1);
+ }
+
+ // Resolve occurrences of "/./" in the normalized path
+ while (true) {
+ int index = normalized.indexOf("/./");
+ if (index < 0)
+ break;
+ normalized = normalized.substring(0, index) +
+ normalized.substring(index + 2);
+ }
+
+ // Resolve occurrences of "/../" in the normalized path
+ while (true) {
+ int index = normalized.indexOf("/../");
+ if (index < 0)
+ break;
+ if (index == 0)
+ return (null); // Trying to go outside our context
+ int index2 = normalized.lastIndexOf('/', index - 1);
+ normalized = normalized.substring(0, index2) +
+ normalized.substring(index + 3);
+ }
+
+ // Return the normalized path that we have completed
+ return (normalized);
+
+ }
+
+
// -------------------------------------------------------- Private Methods
/**
@@ -1528,7 +1593,7 @@
}
// Normalise destination path (remove '.' and '..')
- destinationPath = RequestUtil.normalize(destinationPath);
+ destinationPath = normalize(destinationPath);
String contextPath = req.getContextPath();
if ((contextPath != null) &&
@@ -2275,7 +2340,7 @@
if (!toAppend.startsWith("/"))
toAppend = "/" + toAppend;
- generatedXML.writeText(rewriteUrl(RequestUtil.normalize(absoluteUri + toAppend)));
+ generatedXML.writeText(rewriteUrl(normalize(absoluteUri + toAppend)));
generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/ssi/SSIServletRequestUtil.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/ssi/SSIServletRequestUtil.java 2009-06-04 14:15:54 UTC (rev 1080)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/ssi/SSIServletRequestUtil.java 2009-06-04 15:03:52 UTC (rev 1081)
@@ -59,6 +59,13 @@
* Path to be normalized
*/
public static String normalize(String path) {
- return RequestUtil.normalize(path);
+ if (path == null) return null;
+ String normalized = path;
+ //Why doesn't RequestUtil do this??
+ // Normalize the slashes and add leading slash if necessary
+ if (normalized.indexOf('\\') >= 0)
+ normalized = normalized.replace('\\', '/');
+ normalized = RequestUtil.normalize(path);
+ return normalized;
}
}
\ No newline at end of file
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/util/RequestUtil.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/util/RequestUtil.java 2009-06-04 14:15:54 UTC (rev 1080)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/util/RequestUtil.java 2009-06-04 15:03:52 UTC (rev 1081)
@@ -93,29 +93,13 @@
* @param path Relative path to be normalized
*/
public static String normalize(String path) {
- return normalize(path, true);
- }
- /**
- * Normalize a relative URI path that may have relative values ("/./",
- * "/../", and so on ) it it. <strong>WARNING</strong> - This method is
- * useful only for normalizing application-generated paths. It does not
- * try to perform security checks for malicious input.
- *
- * @param path Relative path to be normalized
- * @param replaceBackSlash Should '\\' be replaced with '/'
- */
- public static String normalize(String path, boolean replaceBackSlash) {
-
if (path == null)
return null;
// Create a place for the normalized path
String normalized = path;
- if (replaceBackSlash && normalized.indexOf('\\') >= 0)
- normalized = normalized.replace('\\', '/');
-
if (normalized.equals("/."))
return "/";
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/naming/resources/FileDirContext.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/naming/resources/FileDirContext.java 2009-06-04 14:15:54 UTC (rev 1080)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/naming/resources/FileDirContext.java 2009-06-04 15:03:52 UTC (rev 1081)
@@ -29,21 +29,14 @@
import java.util.Hashtable;
import javax.naming.NameAlreadyBoundException;
-import javax.naming.NameNotFoundException;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
-import javax.naming.NotContextException;
import javax.naming.OperationNotSupportedException;
-import javax.naming.directory.AttributeModificationException;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
-import javax.naming.directory.InvalidAttributesException;
-import javax.naming.directory.InvalidSearchControlsException;
-import javax.naming.directory.InvalidSearchFilterException;
import javax.naming.directory.ModificationItem;
import javax.naming.directory.SearchControls;
-import org.apache.catalina.util.RequestUtil;
import org.apache.naming.NamingContextBindingsEnumeration;
import org.apache.naming.NamingContextEnumeration;
import org.apache.naming.NamingEntry;
@@ -761,11 +754,61 @@
// ------------------------------------------------------ Protected Methods
- protected static String normalize(String path) {
- return RequestUtil.normalize(path, File.separatorChar == '\\');
+ /**
+ * Return a context-relative path, beginning with a "/", that represents
+ * the canonical version of the specified path after ".." and "." elements
+ * are resolved out. If the specified path attempts to go outside the
+ * boundaries of the current context (i.e. too many ".." path elements
+ * are present), return <code>null</code> instead.
+ *
+ * @param path Path to be normalized
+ */
+ protected String normalize(String path) {
+
+ String normalized = path;
+
+ // Normalize the slashes and add leading slash if necessary
+ if (File.separatorChar == '\\' && normalized.indexOf('\\') >= 0)
+ normalized = normalized.replace('\\', '/');
+ if (!normalized.startsWith("/"))
+ normalized = "/" + normalized;
+
+ // Resolve occurrences of "//" in the normalized path
+ while (true) {
+ int index = normalized.indexOf("//");
+ if (index < 0)
+ break;
+ normalized = normalized.substring(0, index) +
+ normalized.substring(index + 1);
}
+ // Resolve occurrences of "/./" in the normalized path
+ while (true) {
+ int index = normalized.indexOf("/./");
+ if (index < 0)
+ break;
+ normalized = normalized.substring(0, index) +
+ normalized.substring(index + 2);
+ }
+ // Resolve occurrences of "/../" in the normalized path
+ while (true) {
+ int index = normalized.indexOf("/../");
+ if (index < 0)
+ break;
+ if (index == 0)
+ return (null); // Trying to go outside our context
+ int index2 = normalized.lastIndexOf('/', index - 1);
+ normalized = normalized.substring(0, index2) +
+ normalized.substring(index + 3);
+ }
+
+ // Return the normalized path that we have completed
+ return (normalized);
+
+ }
+
+
/**
* Return a File object representing the specified normalized
* context-relative path if it exists and is readable. Otherwise,
15 years, 6 months
JBossWeb SVN: r1080 - in branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache: catalina/core and 4 other directories.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-06-04 10:15:54 -0400 (Thu, 04 Jun 2009)
New Revision: 1080
Modified:
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/Request.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationContext.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationHttpRequest.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/servlets/WebdavServlet.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/ssi/SSIServletRequestUtil.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/util/RequestUtil.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/naming/resources/FileDirContext.java
Log:
Refactor all String based normalization as one. (from r901 in trunk).
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/Request.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/Request.java 2009-06-03 17:26:27 UTC (rev 1079)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/Request.java 2009-06-04 14:15:54 UTC (rev 1080)
@@ -67,7 +67,6 @@
import org.apache.catalina.realm.GenericPrincipal;
import org.apache.catalina.util.Enumerator;
import org.apache.catalina.util.ParameterMap;
-import org.apache.catalina.util.RequestUtil;
import org.apache.catalina.util.StringManager;
import org.apache.catalina.util.StringParser;
@@ -1269,10 +1268,9 @@
int pos = requestPath.lastIndexOf('/');
String relative = null;
if (pos >= 0) {
- relative = RequestUtil.normalize
- (requestPath.substring(0, pos + 1) + path);
+ relative = requestPath.substring(0, pos + 1) + path;
} else {
- relative = RequestUtil.normalize(requestPath + path);
+ relative = requestPath + path;
}
return (context.getServletContext().getRequestDispatcher(relative));
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationContext.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationContext.java 2009-06-03 17:26:27 UTC (rev 1079)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationContext.java 2009-06-04 14:15:54 UTC (rev 1080)
@@ -44,6 +44,7 @@
import org.apache.catalina.Wrapper;
import org.apache.catalina.deploy.ApplicationParameter;
import org.apache.catalina.util.Enumerator;
+import org.apache.catalina.util.RequestUtil;
import org.apache.catalina.util.ResourceSet;
import org.apache.catalina.util.ServerInfo;
import org.apache.catalina.util.StringManager;
@@ -377,7 +378,7 @@
path = path.substring(0, pos);
}
- path = normalize(path);
+ path = RequestUtil.normalize(path);
if (path == null)
return (null);
@@ -459,7 +460,7 @@
throw new MalformedURLException(sm.getString("applicationContext.requestDispatcher.iae", path));
}
- path = normalize(path);
+ path = RequestUtil.normalize(path);
if (path == null)
return (null);
@@ -508,10 +509,13 @@
*/
public InputStream getResourceAsStream(String path) {
- path = normalize(path);
if (path == null)
return (null);
+ path = RequestUtil.normalize(path);
+ if (path == null)
+ return (null);
+
DirContext resources = context.getResources();
if (resources != null) {
try {
@@ -544,7 +548,7 @@
(sm.getString("applicationContext.resourcePaths.iae", path));
}
- path = normalize(path);
+ path = RequestUtil.normalize(path);
if (path == null)
return (null);
@@ -851,45 +855,6 @@
/**
- * Return a context-relative path, beginning with a "/", that represents
- * the canonical version of the specified path after ".." and "." elements
- * are resolved out. If the specified path attempts to go outside the
- * boundaries of the current context (i.e. too many ".." path elements
- * are present), return <code>null</code> instead.
- *
- * @param path Path to be normalized
- */
- private String normalize(String path) {
-
- if (path == null) {
- return null;
- }
-
- String normalized = path;
-
- // Normalize the slashes and add leading slash if necessary
- if (normalized.indexOf('\\') >= 0)
- normalized = normalized.replace('\\', '/');
-
- // Resolve occurrences of "/../" in the normalized path
- while (true) {
- int index = normalized.indexOf("/../");
- if (index < 0)
- break;
- if (index == 0)
- return (null); // Trying to go outside our context
- int index2 = normalized.lastIndexOf('/', index - 1);
- normalized = normalized.substring(0, index2) +
- normalized.substring(index + 3);
- }
-
- // Return the normalized path that we have completed
- return (normalized);
-
- }
-
-
- /**
* Merge the context initialization parameters specified in the application
* deployment descriptor with the application parameters described in the
* server configuration, respecting the <code>override</code> property of
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationHttpRequest.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationHttpRequest.java 2009-06-03 17:26:27 UTC (rev 1079)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationHttpRequest.java 2009-06-04 14:15:54 UTC (rev 1080)
@@ -318,10 +318,9 @@
int pos = requestPath.lastIndexOf('/');
String relative = null;
if (pos >= 0) {
- relative = RequestUtil.normalize
- (requestPath.substring(0, pos + 1) + path);
+ relative = requestPath.substring(0, pos + 1) + path;
} else {
- relative = RequestUtil.normalize(requestPath + path);
+ relative = requestPath + path;
}
return (context.getServletContext().getRequestDispatcher(relative));
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/servlets/WebdavServlet.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/servlets/WebdavServlet.java 2009-06-03 17:26:27 UTC (rev 1079)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/servlets/WebdavServlet.java 2009-06-04 14:15:54 UTC (rev 1080)
@@ -1374,71 +1374,6 @@
}
- /**
- * Return a context-relative path, beginning with a "/", that represents
- * the canonical version of the specified path after ".." and "." elements
- * are resolved out. If the specified path attempts to go outside the
- * boundaries of the current context (i.e. too many ".." path elements
- * are present), return <code>null</code> instead.
- *
- * @param path Path to be normalized
- */
- protected String normalize(String path) {
-
- if (path == null)
- return null;
-
- // Create a place for the normalized path
- String normalized = path;
-
- if (normalized == null)
- return (null);
-
- if (normalized.equals("/."))
- return "/";
-
- // Normalize the slashes and add leading slash if necessary
- if (normalized.indexOf('\\') >= 0)
- normalized = normalized.replace('\\', '/');
- if (!normalized.startsWith("/"))
- normalized = "/" + normalized;
-
- // Resolve occurrences of "//" in the normalized path
- while (true) {
- int index = normalized.indexOf("//");
- if (index < 0)
- break;
- normalized = normalized.substring(0, index) +
- normalized.substring(index + 1);
- }
-
- // Resolve occurrences of "/./" in the normalized path
- while (true) {
- int index = normalized.indexOf("/./");
- if (index < 0)
- break;
- normalized = normalized.substring(0, index) +
- normalized.substring(index + 2);
- }
-
- // Resolve occurrences of "/../" in the normalized path
- while (true) {
- int index = normalized.indexOf("/../");
- if (index < 0)
- break;
- if (index == 0)
- return (null); // Trying to go outside our context
- int index2 = normalized.lastIndexOf('/', index - 1);
- normalized = normalized.substring(0, index2) +
- normalized.substring(index + 3);
- }
-
- // Return the normalized path that we have completed
- return (normalized);
-
- }
-
-
// -------------------------------------------------------- Private Methods
/**
@@ -1593,7 +1528,7 @@
}
// Normalise destination path (remove '.' and '..')
- destinationPath = normalize(destinationPath);
+ destinationPath = RequestUtil.normalize(destinationPath);
String contextPath = req.getContextPath();
if ((contextPath != null) &&
@@ -2340,7 +2275,7 @@
if (!toAppend.startsWith("/"))
toAppend = "/" + toAppend;
- generatedXML.writeText(rewriteUrl(normalize(absoluteUri + toAppend)));
+ generatedXML.writeText(rewriteUrl(RequestUtil.normalize(absoluteUri + toAppend)));
generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/ssi/SSIServletRequestUtil.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/ssi/SSIServletRequestUtil.java 2009-06-03 17:26:27 UTC (rev 1079)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/ssi/SSIServletRequestUtil.java 2009-06-04 14:15:54 UTC (rev 1080)
@@ -59,13 +59,6 @@
* Path to be normalized
*/
public static String normalize(String path) {
- if (path == null) return null;
- String normalized = path;
- //Why doesn't RequestUtil do this??
- // Normalize the slashes and add leading slash if necessary
- if (normalized.indexOf('\\') >= 0)
- normalized = normalized.replace('\\', '/');
- normalized = RequestUtil.normalize(path);
- return normalized;
+ return RequestUtil.normalize(path);
}
}
\ No newline at end of file
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/util/RequestUtil.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/util/RequestUtil.java 2009-06-03 17:26:27 UTC (rev 1079)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/util/RequestUtil.java 2009-06-04 14:15:54 UTC (rev 1080)
@@ -93,13 +93,29 @@
* @param path Relative path to be normalized
*/
public static String normalize(String path) {
+ return normalize(path, true);
+ }
+ /**
+ * Normalize a relative URI path that may have relative values ("/./",
+ * "/../", and so on ) it it. <strong>WARNING</strong> - This method is
+ * useful only for normalizing application-generated paths. It does not
+ * try to perform security checks for malicious input.
+ *
+ * @param path Relative path to be normalized
+ * @param replaceBackSlash Should '\\' be replaced with '/'
+ */
+ public static String normalize(String path, boolean replaceBackSlash) {
+
if (path == null)
return null;
// Create a place for the normalized path
String normalized = path;
+ if (replaceBackSlash && normalized.indexOf('\\') >= 0)
+ normalized = normalized.replace('\\', '/');
+
if (normalized.equals("/."))
return "/";
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/naming/resources/FileDirContext.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/naming/resources/FileDirContext.java 2009-06-03 17:26:27 UTC (rev 1079)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/naming/resources/FileDirContext.java 2009-06-04 14:15:54 UTC (rev 1080)
@@ -29,14 +29,21 @@
import java.util.Hashtable;
import javax.naming.NameAlreadyBoundException;
+import javax.naming.NameNotFoundException;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
+import javax.naming.NotContextException;
import javax.naming.OperationNotSupportedException;
+import javax.naming.directory.AttributeModificationException;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
+import javax.naming.directory.InvalidAttributesException;
+import javax.naming.directory.InvalidSearchControlsException;
+import javax.naming.directory.InvalidSearchFilterException;
import javax.naming.directory.ModificationItem;
import javax.naming.directory.SearchControls;
+import org.apache.catalina.util.RequestUtil;
import org.apache.naming.NamingContextBindingsEnumeration;
import org.apache.naming.NamingContextEnumeration;
import org.apache.naming.NamingEntry;
@@ -754,61 +761,11 @@
// ------------------------------------------------------ Protected Methods
- /**
- * Return a context-relative path, beginning with a "/", that represents
- * the canonical version of the specified path after ".." and "." elements
- * are resolved out. If the specified path attempts to go outside the
- * boundaries of the current context (i.e. too many ".." path elements
- * are present), return <code>null</code> instead.
- *
- * @param path Path to be normalized
- */
- protected String normalize(String path) {
-
- String normalized = path;
-
- // Normalize the slashes and add leading slash if necessary
- if (File.separatorChar == '\\' && normalized.indexOf('\\') >= 0)
- normalized = normalized.replace('\\', '/');
- if (!normalized.startsWith("/"))
- normalized = "/" + normalized;
-
- // Resolve occurrences of "//" in the normalized path
- while (true) {
- int index = normalized.indexOf("//");
- if (index < 0)
- break;
- normalized = normalized.substring(0, index) +
- normalized.substring(index + 1);
+ protected static String normalize(String path) {
+ return RequestUtil.normalize(path, File.separatorChar == '\\');
}
- // Resolve occurrences of "/./" in the normalized path
- while (true) {
- int index = normalized.indexOf("/./");
- if (index < 0)
- break;
- normalized = normalized.substring(0, index) +
- normalized.substring(index + 2);
- }
- // Resolve occurrences of "/../" in the normalized path
- while (true) {
- int index = normalized.indexOf("/../");
- if (index < 0)
- break;
- if (index == 0)
- return (null); // Trying to go outside our context
- int index2 = normalized.lastIndexOf('/', index - 1);
- normalized = normalized.substring(0, index2) +
- normalized.substring(index + 3);
- }
-
- // Return the normalized path that we have completed
- return (normalized);
-
- }
-
-
/**
* Return a File object representing the specified normalized
* context-relative path if it exists and is readable. Otherwise,
15 years, 6 months
JBossWeb SVN: r1079 - branches/JBOSSWEB_2_0_0_GA_CP.
by jbossweb-commits@lists.jboss.org
Author: mmillson
Date: 2009-06-03 13:26:27 -0400 (Wed, 03 Jun 2009)
New Revision: 1079
Modified:
branches/JBOSSWEB_2_0_0_GA_CP/build.xml
Log:
"Define javac target for [JBWEB-140]."
Modified: branches/JBOSSWEB_2_0_0_GA_CP/build.xml
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/build.xml 2009-06-03 15:47:47 UTC (rev 1078)
+++ branches/JBOSSWEB_2_0_0_GA_CP/build.xml 2009-06-03 17:26:27 UTC (rev 1079)
@@ -45,10 +45,14 @@
<!-- Some compilers will disable debugging if true. And it doesn't do anything
in most cases -->
- <property name="compile.optimize" value="false"/>
- <property name="compile.debug" value="true" />
- <property name="compile.deprecation" value="false" />
- <property name="compile.source" value="1.5" />
+ <property name="compile.optimize" value="false"/>
+ <property name="compile.debug" value="true" />
+ <property name="compile.deprecation" value="false" />
+ <property name="compile.source" value="1.5" />
+ <property name="compile.target" value="1.5" />
+ <!-- Define ant.build.javac.target, the default javac target with ant 1.7, for cases
+ when the javac target property is ignored (e.g. FC10 x86-64 OpenJDK 64-Bit). -->
+ <property name="ant.build.javac.target" value="1.5" />
<path id="catalina.classpath">
<fileset dir="lib">
@@ -101,6 +105,7 @@
debug="${compile.debug}"
deprecation="${compile.deprecation}"
source="${compile.source}"
+ target="${compile.target}"
optimize="${compile.optimize}"
excludes="**/CVS/**,**/.svn/**">
<classpath refid="catalina.classpath" />
15 years, 6 months