Skip to content

Node.js based forum software built for the modern web

chore: up markdown, ignore ? in image paths

Barış Soner Uşaklı03e0e4495b0e
diff --git a/install/package.json b/install/package.json
index 61c316b569..05c7d55b43 100644
--- a/install/package.json
+++ b/install/package.json
@@ -108,7 +108,7 @@
"nodebb-plugin-emoji": "6.0.19",
"nodebb-plugin-emoji-android": "4.1.1",
"nodebb-plugin-link-preview": "2.2.9",
- "nodebb-plugin-markdown": "13.2.11",
+ "nodebb-plugin-markdown": "13.2.12",
"nodebb-plugin-mentions": "5.0.4",
"nodebb-plugin-spam-be-gone": "2.3.12",
"nodebb-plugin-web-push": "0.9.5",
diff --git a/src/posts/uploads.js b/src/posts/uploads.js
index 749b0b2cc9..d7a2021451 100644
--- a/src/posts/uploads.js
+++ b/src/posts/uploads.js
@@ -22,7 +22,7 @@ module.exports = function (Posts) {
const md5 = filename => crypto.createHash('md5').update(filename).digest('hex');
const upload_path = nconf.get('upload_path');
- const searchRegex = /\/assets\/uploads(\/files\/[^\s")@]+\.?[\w]*)/g;
+ const searchRegex = /\/assets\/uploads(\/files\/[^\s")@?]+\.?[\w]*)/g;
const _getFullPath = relativePath => path.join(upload_path, relativePath);
const _filterValidPaths = async function (filePaths) {
diff --git a/test/uploads.js b/test/uploads.js
index 1f50cbb51e..29266d382e 100644
--- a/test/uploads.js
+++ b/test/uploads.js
@@ -851,7 +851,7 @@ describe('Upload Controllers', () => {
});
});
- describe('.getUploadsForPost() should ignore @ suffixes after file path', () => {
+ describe('.getUploadsForPost() should ignore ? suffixes after file path', () => {
let relPath;
const relativePath = nconf.get('relative_path') || '';
before(async () => {
@@ -860,20 +860,20 @@ describe('Upload Controllers', () => {
relPath = body.response.images[0].url.slice(body.response.images[0].url.indexOf('/files/'));
});
- it('should strip a width x height suffix (@1920x1080)', async () => {
- const content = `![alt](${relativePath}/assets/uploads${relPath}@1920x1080)`;
+ it('should strip a width x height suffix (?w=1920&h=1080)', async () => {
+ const content = `![alt](${relativePath}/assets/uploads${relPath}?w=1920&h=1080)`;
const uploads = await posts.uploads.getUploadsForPost({ tid: 0, content }, false);
assert.deepStrictEqual(uploads, [relPath]);
});
- it('should strip a percentage suffix (@50%)', async () => {
- const content = `![alt](${relativePath}/assets/uploads${relPath}@50%)`;
+ it('should strip a percentage suffix (?w=50%)', async () => {
+ const content = `![alt](${relativePath}/assets/uploads${relPath}?w=50%)`;
const uploads = await posts.uploads.getUploadsForPost({ tid: 0, content }, false);
assert.deepStrictEqual(uploads, [relPath]);
});
- it('should strip a width-only/multiplier suffix (@200)', async () => {
- const content = `![alt](${relativePath}/assets/uploads${relPath}@200)`;
+ it('should strip a width-only/multiplier suffix (?w=200)', async () => {
+ const content = `![alt](${relativePath}/assets/uploads${relPath}?w=200)`;
const uploads = await posts.uploads.getUploadsForPost({ tid: 0, content }, false);
assert.deepStrictEqual(uploads, [relPath]);
});