FIX: encode image filename so '[', ']' and '|' doesn't break the markdown
This commit is contained in:
parent
645c32758a
commit
f674b9e86e
|
@ -291,13 +291,13 @@ function isGUID(value) {
|
||||||
|
|
||||||
function imageNameFromFileName(fileName) {
|
function imageNameFromFileName(fileName) {
|
||||||
const split = fileName.split('.');
|
const split = fileName.split('.');
|
||||||
const name = split[split.length-2];
|
let name = split[split.length - 2];
|
||||||
|
|
||||||
if (exports.isAppleDevice() && isGUID(name)) {
|
if (exports.isAppleDevice() && isGUID(name)) {
|
||||||
return I18n.t('upload_selector.default_image_alt_text');
|
name = I18n.t('upload_selector.default_image_alt_text');
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return encodeURIComponent(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function allowsImages() {
|
export function allowsImages() {
|
||||||
|
|
|
@ -123,6 +123,7 @@ var testUploadMarkdown = function(filename) {
|
||||||
|
|
||||||
QUnit.test("getUploadMarkdown", assert => {
|
QUnit.test("getUploadMarkdown", assert => {
|
||||||
assert.equal(testUploadMarkdown("lolcat.gif"),'![lolcat|100x200](/uploads/123/abcdef.ext)');
|
assert.equal(testUploadMarkdown("lolcat.gif"),'![lolcat|100x200](/uploads/123/abcdef.ext)');
|
||||||
|
assert.equal(testUploadMarkdown("[foo|bar].png"),'![%5Bfoo%7Cbar%5D|100x200](/uploads/123/abcdef.ext)');
|
||||||
assert.ok(testUploadMarkdown("important.txt") === '<a class="attachment" href="/uploads/123/abcdef.ext">important.txt</a> (42 Bytes)\n');
|
assert.ok(testUploadMarkdown("important.txt") === '<a class="attachment" href="/uploads/123/abcdef.ext">important.txt</a> (42 Bytes)\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue