caldav-adapter 7.2.0 → 8.0.1

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.
@@ -2,12 +2,23 @@ const raw = require('raw-body');
2
2
  const { DOMParser } = require('@xmldom/xmldom');
3
3
 
4
4
  module.exports = async function (ctx) {
5
- ctx.request.body = await raw(ctx.req, {
6
- encoding: true,
7
- limit: '1mb' // Practical
8
- });
5
+ try {
6
+ ctx.request.body = await raw(ctx.req, {
7
+ encoding: true,
8
+ limit: '10mb' // Practical
9
+ });
10
+ } catch (err) {
11
+ // <https://github.com/stream-utils/raw-body/blob/f62e660e7c50891844f5615de075ab145c1f6129/README.md?plain=1#L82-L116>
12
+ if (ctx?.app?.emit) ctx.app.emit('error', err, ctx);
13
+ else throw err;
14
+ }
9
15
 
10
16
  if (ctx.request.type.includes('xml')) {
11
- ctx.request.xml = new DOMParser().parseFromString(ctx.request.body);
17
+ try {
18
+ ctx.request.xml = new DOMParser().parseFromString(ctx.request.body);
19
+ } catch (err) {
20
+ if (ctx?.app?.emit) ctx.app.emit('error', err, ctx);
21
+ else throw err;
22
+ }
12
23
  }
13
24
  };
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": "7.2.0",
4
+ "version": "8.0.1",
5
5
  "author": "Sanders DeNardi and Forward Email LLC",
6
6
  "contributors": [
7
7
  "Sanders DeNardi <sedenardi@gmail.com> (http://www.sandersdenardi.com/)",