fix: Add application/octet-stream as a valid mimetype for docx uploads (#2105)

* fix: Add application/octet-stream as a valid mimetype for docx uploads

* fix: Include application/octet-stream in frontend filter
fix: Add file size and file type guards

* Validate .docx extension in files with application/octet-stream mimetype

* refactor: Move MAXIMUM_IMPORT_SIZE to an optional environment config
fix: Add file size check on server too

Co-authored-by: Saumya Pandey <sp160899@gmail.com>
This commit is contained in:
Tom Moor
2021-05-05 18:48:37 -07:00
committed by GitHub
parent 6ef8d9ddb3
commit 69802cc985
7 changed files with 100 additions and 1 deletions

View File

@ -44,6 +44,10 @@ const importMapping: ImportableFile[] = [
type: "application/msword",
getMarkdown: confluenceToMarkdown,
},
{
type: "application/octet-stream",
getMarkdown: docxToMarkdown,
},
{
type:
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
@ -142,6 +146,12 @@ export default async function documentImporter({
}): Promise<{ text: string, title: string }> {
const fileInfo = importMapping.filter((item) => {
if (item.type === file.type) {
if (
file.type === "application/octet-stream" &&
path.extname(file.name) !== ".docx"
) {
return false;
}
return true;
}
if (item.type === "text/markdown" && path.extname(file.name) === ".md") {