Permalink
Browse files

fixed syntax errors and bugs in the response property serialization

  • Loading branch information...
1 parent 1f2c18e commit 3b8b6d53f490f9042175a05d99a7b89dc4220db9 @mikedeboer committed Jan 26, 2013
Showing with 16 additions and 13 deletions.
  1. +7 −7 lib/DAV/handler.js
  2. +5 −5 lib/DAV/property/response.js
  3. +4 −1 lib/shared/xml.js
View
@@ -692,7 +692,7 @@ jsDAV_Handler.STATUS_MAP = {
if (!Util.empty(err))
return self.handleError(err);
//if (jsDAV.debugMode)
- // Util.log("data received " + data);
+ // Util.log("{" + self.id + "}", "data received " + data);
self.parsePropfindRequest(data, function(err, requestedProperties) {
if (!Util.empty(err))
return self.handleError(err);
@@ -730,7 +730,7 @@ jsDAV_Handler.STATUS_MAP = {
self.httpResponse.writeHead(207, {
"content-type": "application/xml; charset=utf-8",
"vary": "Brief,Prefer",
- "DAV": features.join(",");
+ "DAV": features.join(",")
});
var prefer = self.getHTTPPrefer();
self.httpResponse.end(self.generateMultiStatus(newProperties, prefer["return-minimal"]));
@@ -755,22 +755,22 @@ jsDAV_Handler.STATUS_MAP = {
if (!Util.empty(err))
return self.handleError(err);
//if (jsDAV.debugMode)
- // Util.log("data received " + data);
+ // Util.log("{" + self.id + "}", "data received " + data);
self.parseProppatchRequest(data, function(err, newProperties) {
if (!Util.empty(err))
return self.handleError(err);
self.updateProperties(self.getRequestUri(), newProperties, function(err, result) {
if (!Util.empty(err))
return self.handleError(err);
- var prefer = this.getHTTPPrefer();
+ var prefer = self.getHTTPPrefer();
if (prefer["return-minimal"]) {
// If return-minimal is specified, we only have to check if the
// request was succesful, and don't need to return the
// multi-status.
var prop;
var ok = true;
- for (code in result) {
+ for (var code in result) {
prop = result[code];
if (parseInt(code, 10) > 299) {
ok = false;
@@ -1610,8 +1610,8 @@ jsDAV_Handler.STATUS_MAP = {
nodes[path] = parentNode;
nodesPath.push(path);
- if (jsDAV.debugMode)
- console.log("getPropertiesForPath", depth, parentNode,parentNode.hasFeature(jsDAV_iCollection));
+ //if (jsDAV.debugMode)
+ // console.log("getPropertiesForPath", depth, parentNode,parentNode.hasFeature(jsDAV_iCollection));
if (depth == 1 && parentNode.hasFeature(jsDAV_iCollection)) {
parentNode.getChildren(function(err, cNodes) {
if (!Util.empty(err))
@@ -56,7 +56,7 @@ var jsDAV_Property_Response = module.exports = jsDAV_Property.extend({
// The properties variable is an array containing properties, grouped by
// HTTP status
var resHttpStatus, resPropertyGroup, resPropertyName, resPropertyValue,
- resPropName, resNodeName, resCurrentProperty;
+ resPropName, resPrefix, resNodeName, resCurrentProperty;
var resNsList = Util.extend({}, Xml.xmlNamespaces);
@@ -83,7 +83,7 @@ var jsDAV_Property_Response = module.exports = jsDAV_Property.extend({
// special case for empty namespaces
if (!resPropName || resPropName[1] === "") {
- resNodeName = resPropertyName;
+ resNodeName = resPropName[2];
resCurrentProperty = "<" + resNodeName + " xmlns=\"\"";
}
else {
@@ -97,8 +97,9 @@ var jsDAV_Property_Response = module.exports = jsDAV_Property.extend({
resCurrentProperty = "<" + resNodeName;
}
else {
- resNodeName = resNsList[resPropName[1]] + ":" + resPropName[2];
- resCurrentProperty = "<" + resNodeName + " xmlns=\"" + resPropName[1] + "\"";
+ resPrefix = resNsList[resPropName[1]];
+ resNodeName = resPrefix + ":" + resPropName[2];
+ resCurrentProperty = "<" + resNodeName + " xmlns:" + resPrefix + "=\"" + resPropName[1] + "\"";
}
}
@@ -111,7 +112,6 @@ var jsDAV_Property_Response = module.exports = jsDAV_Property.extend({
+ "</" + resNodeName + ">";
}
else if (resPropertyValue) {
- console.dir(resPropertyValue);
throw new Exc.jsDAV_Exception("Unknown property value type: "
+ resPropertyValue + " for property: " + resPropertyName);
}
View
@@ -162,9 +162,12 @@ exports.loadDOMDocument = function(xml, which, callback) {
var root;
var parser = which == "xmldom" ? require("xmldom").DOMParser : require("libxml/lib/libxml");
xml = exports.convertDAVNamespace(xml);
+ function onError() {
+ console.log("XMLERROR", arguments);
+ }
try {
root = which == "xmldom"
- ? new parser().parseFromString(xml, "text/xml").documentElement
+ ? new parser({errorHandler:{warning:onError,error:onError,fatalError:onError}}).parseFromString(xml, "text/xml").documentElement
: exports.xmlParseError(parser.parseFromString(xml).documentElement);
}
catch (ex) {

0 comments on commit 3b8b6d5

Please sign in to comment.