caldav-adapter 8.3.1 → 8.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "caldav-adapter",
|
|
3
3
|
"description": "CalDAV server for Node.js and Koa. Modernized and maintained for Forward Email.",
|
|
4
|
-
"version": "8.3.
|
|
4
|
+
"version": "8.3.3",
|
|
5
5
|
"author": "Sanders DeNardi and Forward Email LLC",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Sanders DeNardi <sedenardi@gmail.com> (http://www.sandersdenardi.com/)",
|
|
@@ -18,6 +18,24 @@ module.exports = function (options) {
|
|
|
18
18
|
'sync-collection': sync(options)
|
|
19
19
|
};
|
|
20
20
|
const exec = async function (ctx, calendar) {
|
|
21
|
+
//
|
|
22
|
+
// Check if XML was parsed successfully
|
|
23
|
+
// Per RFC 4918 Section 8.2: "If a server receives XML that is not
|
|
24
|
+
// well-formed, then the server MUST reject the entire request with
|
|
25
|
+
// a 400 (Bad Request)."
|
|
26
|
+
//
|
|
27
|
+
// ctx.request.xml can be null if:
|
|
28
|
+
// 1. The XML body is empty
|
|
29
|
+
// 2. The XML body is malformed and fails to parse
|
|
30
|
+
// 3. The Content-Type is incorrect
|
|
31
|
+
//
|
|
32
|
+
if (!ctx.request.xml || !ctx.request.xml.documentElement) {
|
|
33
|
+
log.debug('report rejected: invalid or empty XML body');
|
|
34
|
+
ctx.status = 400;
|
|
35
|
+
ctx.body = 'Bad Request: invalid or missing XML body';
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
21
39
|
const rootTag = ctx.request.xml.documentElement.localName;
|
|
22
40
|
const rootAction = rootActions[rootTag];
|
|
23
41
|
log.debug(`report ${rootAction ? 'hit' : 'miss'}: ${rootTag}`);
|
|
@@ -65,16 +65,25 @@ module.exports = function (options) {
|
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
try {
|
|
69
|
+
if (typeof calMethods[method].exec === 'function') {
|
|
70
|
+
setMultistatusResponse(ctx);
|
|
71
|
+
ctx.body = await calMethods[method].exec(ctx, calendar);
|
|
72
|
+
} else if (typeof calMethods[method] === 'function') {
|
|
73
|
+
setMultistatusResponse(ctx);
|
|
74
|
+
ctx.body = await calMethods[method](ctx, calendar);
|
|
75
|
+
} else {
|
|
76
|
+
log.warn(`method handler not found: ${method}`);
|
|
77
|
+
setMissingMethod(ctx);
|
|
78
|
+
ctx.body = notFound(ctx.url);
|
|
79
|
+
}
|
|
80
|
+
} catch (err) {
|
|
81
|
+
err.isCodeBug = true;
|
|
82
|
+
err.calendarId = calendarId;
|
|
83
|
+
err.principalId = ctx.state.params.principalId;
|
|
84
|
+
err.method = method;
|
|
85
|
+
log.error('calendar method error', err);
|
|
86
|
+
throw err;
|
|
78
87
|
}
|
|
79
88
|
} else {
|
|
80
89
|
if (method === 'options') {
|
|
@@ -89,16 +98,24 @@ module.exports = function (options) {
|
|
|
89
98
|
return;
|
|
90
99
|
}
|
|
91
100
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
try {
|
|
102
|
+
if (typeof userMethods[method].exec === 'function') {
|
|
103
|
+
setMultistatusResponse(ctx);
|
|
104
|
+
ctx.body = await userMethods[method].exec(ctx);
|
|
105
|
+
} else if (typeof userMethods[method] === 'function') {
|
|
106
|
+
setMultistatusResponse(ctx);
|
|
107
|
+
ctx.body = await userMethods[method](ctx);
|
|
108
|
+
} else {
|
|
109
|
+
log.warn(`method handler not found: ${method}`);
|
|
110
|
+
setMissingMethod(ctx);
|
|
111
|
+
ctx.body = notFound(ctx.url);
|
|
112
|
+
}
|
|
113
|
+
} catch (err) {
|
|
114
|
+
err.isCodeBug = true;
|
|
115
|
+
err.principalId = ctx.state.params.principalId;
|
|
116
|
+
err.method = method;
|
|
117
|
+
log.error('user method error', err);
|
|
118
|
+
throw err;
|
|
102
119
|
}
|
|
103
120
|
}
|
|
104
121
|
};
|