nodebb-plugin-markdown 13.2.9 → 13.2.11

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/index.js CHANGED
@@ -340,8 +340,13 @@ const Markdown = {
340
340
  const token = tokens[idx];
341
341
  const attributes = new Map(token.attrs);
342
342
  if (env.type === 'plaintext') {
343
- const filename = path.basename(attributes.get('src'));
344
- return `[image: ${filename}]`;
343
+ // The alt text is what the author wrote, so prefer it over the stored
344
+ // filename, which carries an upload timestamp (and a uuid, for pasted
345
+ // uploads) that reads as noise in teasers and other plaintext contexts.
346
+ // token.content is the raw alt text, so it is escaped here the way the
347
+ // text rule escapes the rest of the plaintext output
348
+ const label = token.content || path.basename(attributes.get('src'));
349
+ return `[image: ${parser.utils.escapeHtml(label)}]`;
345
350
  }
346
351
 
347
352
  // Validate the url
@@ -27,7 +27,7 @@ Controllers.retrieveRaw = async function (req, res, next) {
27
27
  if (!pid) {
28
28
  return next();
29
29
  }
30
- const content = await postsAPI.getRawPost({ uid: req.uid }, { pid });
30
+ const content = await postsAPI.getRaw({ uid: req.uid }, { pid });
31
31
  if (content === null) {
32
32
  return next();
33
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-markdown",
3
- "version": "13.2.9",
3
+ "version": "13.2.11",
4
4
  "description": "A Markdown parser for NodeBB",
5
5
  "main": "index.js",
6
6
  "repository": {
package/websockets.js CHANGED
@@ -7,7 +7,7 @@ const posts = nodebb.require('./src/posts');
7
7
  module.exports.checkbox = {
8
8
  edit: async function (socket, data) {
9
9
  const canEdit = await privileges.posts.canEdit(data.pid, socket.uid);
10
- if (!canEdit) {
10
+ if (!canEdit.flag) {
11
11
  throw new Error('[[error:no-privileges]]');
12
12
  }
13
13