caldav-adapter 8.2.6 → 8.2.8

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.2.6",
4
+ "version": "8.2.8",
5
5
  "author": "Sanders DeNardi and Forward Email LLC",
6
6
  "contributors": [
7
7
  "Sanders DeNardi <sedenardi@gmail.com> (http://www.sandersdenardi.com/)",
@@ -1,29 +1,5 @@
1
1
  const { setMissingMethod } = require('../../../common/response');
2
2
  const winston = require('../../../common/winston');
3
- const {
4
- response,
5
- status,
6
- build,
7
- multistatus
8
- } = require('../../../common/x-build');
9
-
10
- /**
11
- * Encode special characters for XML content to prevent parsing errors
12
- * @param {string} str - String to encode
13
- * @returns {string} - XML-safe encoded string
14
- */
15
- function encodeXMLEntities(str) {
16
- if (typeof str !== 'string') {
17
- return str;
18
- }
19
-
20
- return str
21
- .replaceAll('&', '&amp;') // Must be first to avoid double-encoding
22
- .replaceAll('<', '&lt;')
23
- .replaceAll('>', '&gt;')
24
- .replaceAll('"', '&quot;')
25
- .replaceAll("'", '&#39;');
26
- }
27
3
 
28
4
  module.exports = function (options) {
29
5
  const log = winston({ ...options, label: 'calendar/get' });
@@ -39,24 +15,10 @@ module.exports = function (options) {
39
15
 
40
16
  const ics = await options.data.buildICS(ctx, events, calendar);
41
17
 
42
- const accept = ctx.accepts(['text/xml', 'text/calendar']);
43
-
44
- if (accept === 'text/xml') {
45
- const responseObj = response(ctx.url, status[200], [
46
- {
47
- 'D:getetag': options.data.getETag(ctx, calendar)
48
- },
49
- {
50
- 'CAL:calendar-data': encodeXMLEntities(ics)
51
- }
52
- ]);
53
- return build(multistatus([responseObj]));
54
- }
55
-
56
- // text/calendar
57
- // application/ics
58
- // text/x-vcalendar
59
- // application/octet-stream
18
+ ctx.status = 200;
19
+ ctx.remove('DAV');
20
+ ctx.set('Content-Type', 'text/calendar; charset=utf-8');
21
+ ctx.set('ETag', options.data.getETag(ctx, calendar));
60
22
  return ics;
61
23
  }
62
24
 
@@ -75,24 +37,10 @@ module.exports = function (options) {
75
37
 
76
38
  const ics = await options.data.buildICS(ctx, event, calendar);
77
39
 
78
- const accept = ctx.accepts(['text/xml', 'text/calendar']);
79
-
80
- if (accept === 'text/xml') {
81
- const responseObj = response(ctx.url, status[200], [
82
- {
83
- 'D:getetag': options.data.getETag(ctx, calendar)
84
- },
85
- {
86
- 'CAL:calendar-data': encodeXMLEntities(ics)
87
- }
88
- ]);
89
- return build(multistatus([responseObj]));
90
- }
91
-
92
- // text/calendar
93
- // application/ics
94
- // text/x-vcalendar
95
- // application/octet-stream
40
+ ctx.status = 200;
41
+ ctx.remove('DAV');
42
+ ctx.set('Content-Type', 'text/calendar; charset=utf-8');
43
+ ctx.set('ETag', options.data.getETag(ctx, calendar));
96
44
  return ics;
97
45
  };
98
46