You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by ma...@apache.org on 2005/01/22 19:53:34 UTC
cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/method PropFindMethod.java
masonjm 2005/01/22 10:53:34
Modified: src/webdav/server/org/apache/slide/webdav/method
PropFindMethod.java
Log:
Ignore non-DAV: elements when parsing a propfind request
Revision Changes Path
1.114 +43 -28 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java
Index: PropFindMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -r1.113 -r1.114
--- PropFindMethod.java 30 Dec 2004 13:38:59 -0000 1.113
+++ PropFindMethod.java 22 Jan 2005 18:53:34 -0000 1.114
@@ -73,6 +73,11 @@
ReadMethod, FineGrainedLockingMethod {
/**
+ * Invalid propfind type.
+ */
+ protected static final int FIND_ERROR = -1;
+
+ /**
* Specify a property mask.
*/
protected static final int FIND_BY_PROPERTY = 0;
@@ -89,6 +94,11 @@
*/
protected static final int FIND_PROPERTY_NAMES = 2;
+ /**
+ * Constant for "DAV:" namespace uri
+ */
+ protected static final String DAV_NAMESPACE_URI = "DAV:";
+
// ----------------------------------------------------- Instance Variables
@@ -194,7 +204,7 @@
// readRequestContent();
depth = INFINITY;
- propFindType = FIND_ALL_PROP;
+ propFindType = FIND_ERROR;
extendedAllprop = getBooleanInitParameter( "extendedAllprop" );
outputOptimized = getBooleanInitParameter( "optimizePropfindOutput" );
@@ -221,32 +231,37 @@
try {
Element element = parseRequestContent(E_PROPFIND);
- try {
- element = (Element)element.getChildren().get(0);
- }
- catch (Exception e) {
+ Iterator elementsIt = element.getChildren().iterator();
+ if (!elementsIt.hasNext()) {
int statusCode = WebdavStatus.SC_BAD_REQUEST;
- sendError( statusCode, getClass().getName()+".missingRootElementChildren", new Object[]{"DAV:"+E_PROPFIND} );
- throw new WebdavException( statusCode );
+ sendError(statusCode, getClass().getName()+".missingRootElementChildren", new Object[]{"DAV:"+E_PROPFIND});
+ throw new WebdavException(statusCode);
+ } else {
+ // Loop through child elements looking for a valid propfind type
+ while (elementsIt.hasNext()) {
+ element = (Element)elementsIt.next();
+ if (element.getNamespaceURI().equals(DAV_NAMESPACE_URI)) {
+
+ if (element.getName().equalsIgnoreCase(E_PROPNAME)){
+ propFindType = FIND_PROPERTY_NAMES;
+ }
+ else if (element.getName().equalsIgnoreCase(E_PROP)) {
+ requestedProperties = new RequestedPropertiesImpl(element);
+ propFindType = FIND_BY_PROPERTY;
+ }
+ else if (element.getName().equalsIgnoreCase(E_ALLPROP)) {
+ requestedProperties = new RequestedPropertiesImpl(element);
+ propFindType = FIND_ALL_PROP;
+ }
+ }
+ }
+ // If no valid values were found, throw an error
+ if (propFindType == FIND_ERROR) {
+ int statusCode = WebdavStatus.SC_BAD_REQUEST;
+ sendError(statusCode, getClass().getName()+".invalidChildOfRootElement", new Object[]{element.getNamespace()+":"+element.getName(),"DAV:"+E_PROPFIND});
+ throw new WebdavException(statusCode);
+ }
}
-
- if (element.getName().equalsIgnoreCase(E_PROPNAME)){
- propFindType = FIND_PROPERTY_NAMES;
- }
- else if ( element.getName().equalsIgnoreCase(E_PROP) ) {
- requestedProperties = new RequestedPropertiesImpl(element);
- propFindType = FIND_BY_PROPERTY;
- }
- else if ( element.getName().equalsIgnoreCase(E_ALLPROP) ) {
- requestedProperties = new RequestedPropertiesImpl(element);
- propFindType = FIND_ALL_PROP;
- }
- else {
- int statusCode = WebdavStatus.SC_BAD_REQUEST;
- sendError( statusCode, getClass().getName()+".invalidChildOfRootElement", new Object[]{element.getNamespace()+":"+element.getName(),"DAV:"+E_PROPFIND} );
- throw new WebdavException( statusCode );
- }
-
}
catch (JDOMException e){
int statusCode = WebdavStatus.SC_BAD_REQUEST;
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org