FIX: be more tactical with replacing markdown chars

* instead of using encodeURIComponent in imageNameFromFileName,
  we just replace the bad characters that we wanted to get rid
  of in the first place where we introduced encodeURIComponent.
  as per review
This commit is contained in:
Martin Brennan 2019-11-25 16:38:13 +10:00
parent b89e634dd4
commit dbfe9540fa
2 changed files with 4 additions and 2 deletions

View File

@ -14,7 +14,9 @@ function imageNameFromFileName(fileName) {
name = I18n.t("upload_selector.default_image_alt_text");
}
return encodeURIComponent(name).replace(/%20/g, " ");
return name.replace(/\[|\]|\|/g, "");
// return encodeURIComponent(name).replace(/%20/g, " ");
}
export function validateUploadedFiles(files, opts) {

View File

@ -198,7 +198,7 @@ QUnit.test("getUploadMarkdown", assert => {
);
assert.equal(
testUploadMarkdown("[foo|bar].png"),
"![%5Bfoo%7Cbar%5D|100x200](/uploads/123/abcdef.ext)"
"![foobar|100x200](/uploads/123/abcdef.ext)"
);
assert.equal(
testUploadMarkdown("file name with space.png"),