Skip to content

Node.js based forum software built for the modern web

fix: send type in api response, trim whitespace from stacktrace, escape stack trace

Julian Lam1b663d3e928b
diff --git a/src/controllers/admin/federation.js b/src/controllers/admin/federation.js
index 4b9aa604e0..35bc678198 100644
--- a/src/controllers/admin/federation.js
+++ b/src/controllers/admin/federation.js
@@ -1,5 +1,7 @@
'use strict';
+const validator = require('validator');
+
const db = require('../../database');
const activitypub = require('../../activitypub');
const analytics = require('../../analytics');
@@ -93,17 +95,18 @@ federationController.errors = async function (req, res) {
if (!errorObj[idx]) {
return null;
}
- let { body, stack } = errorObj[idx];
+ let { type, body, stack } = errorObj[idx];
let hostname = 'Invalid hostname';
const timestampISO = new Date(timestamp).toISOString();
try {
body = JSON.stringify(JSON.parse(body), null, 4);
+ stack = validator.escape(stack.replace(/\s+$/gm, ''));
({ hostname } = new URL(id));
} catch (e) {
// noop
}
- return { id, body, stack, hostname, timestamp, timestampISO };
+ return { id, type, body, stack, hostname, timestamp, timestampISO };
}).filter(Boolean);
res.render('admin/federation/errors', {
diff --git a/src/views/admin/federation/errors.tpl b/src/views/admin/federation/errors.tpl
index ad85844ad7..3a0a1d3574 100644
--- a/src/views/admin/federation/errors.tpl
+++ b/src/views/admin/federation/errors.tpl
@@ -20,12 +20,6 @@
{{{ if ./stack }}}
<pre class="m-2 border p-2"><code>{./stack}</code></pre>
{{{ end }}}
-
- {{{ if ./body }}}
- <!-- <pre class="m-2 border p-2"><code>{./body}</code></pre> -->
- {{{ else }}}
- <em>[[admin/settings/activitypub:errors.payload-gone]]</em>
- {{{ end }}}
</details>
{{{ end }}}
</div>