diff options
| author | Shulhan <ms@kilabit.info> | 2023-11-15 23:38:26 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-11-16 00:54:55 +0700 |
| commit | c96e06ab3b4e49dfe5bdb501d3a621e7deba29be (patch) | |
| tree | 631930a08844aecaa24739a62aed575b4d55cb57 /_wui | |
| parent | 5fd7868ea2fed0d977a55333faa79c31c3289b71 (diff) | |
| download | awwan-c96e06ab3b4e49dfe5bdb501d3a621e7deba29be.tar.xz | |
_wui: allow all content type but decrease max file size to 100KB
Previously, only file with type json, message, octet-stream, script,
text, or xml that can be opened by editor.
In this changes we allow all files as long as the size is less than 100KB.
Diffstat (limited to '_wui')
| -rw-r--r-- | _wui/awwan.ts | 22 | ||||
| -rw-r--r-- | _wui/main.js | 8 |
2 files changed, 3 insertions, 27 deletions
diff --git a/_wui/awwan.ts b/_wui/awwan.ts index 6e6bbc2..8ee224a 100644 --- a/_wui/awwan.ts +++ b/_wui/awwan.ts @@ -23,7 +23,7 @@ const ID_VFS = "com_vfs"; const ID_VFS_PATH = "vfs_path"; const ID_OUTPUT = "output"; const ID_OUTPUT_WRAPPER = "output_wrapper"; -const MAX_FILE_SIZE = 3000000; +const MAX_FILE_SIZE = 102400; // 100KB interface RequestInterface { mode: string; @@ -360,26 +360,10 @@ export class Awwan { message: "", }; - let isTypeAllowed = false; - if ( - node.content_type && - (node.content_type.indexOf("json") >= 0 || - node.content_type.indexOf("message") >= 0 || - node.content_type.indexOf("octet-stream") >= 0 || - node.content_type.indexOf("script") >= 0 || - node.content_type.indexOf("text") >= 0 || - node.content_type.indexOf("xml") >= 0) - ) { - isTypeAllowed = true; - } - if (!isTypeAllowed) { - res.message = `The file "${node.name}" with content type "${node.content_type}" is not allowed to be opened`; - return res; - } if (node.size && node.size > MAX_FILE_SIZE) { res.message = `The file "${node.name}" with size ${ - node.size / 1000000 - }MB is greater than maximum ${MAX_FILE_SIZE / 1000000}MB.`; + node.size / 1024 + }KB is greater than maximum ${MAX_FILE_SIZE / 1000}KB.`; return res; } res.code = 200; diff --git a/_wui/main.js b/_wui/main.js index 929774d..7fdcddf 100644 --- a/_wui/main.js +++ b/_wui/main.js @@ -732,14 +732,6 @@ var awwan = (() => { code: 412, message: "" }; - let isTypeAllowed = false; - if (node.content_type && (node.content_type.indexOf("json") >= 0 || node.content_type.indexOf("message") >= 0 || node.content_type.indexOf("octet-stream") >= 0 || node.content_type.indexOf("script") >= 0 || node.content_type.indexOf("text") >= 0 || node.content_type.indexOf("xml") >= 0)) { - isTypeAllowed = true; - } - if (!isTypeAllowed) { - res2.message = `The file "${node.name}" with content type "${node.content_type}" is not allowed to be opened`; - return res2; - } if (node.size && node.size > MAX_FILE_SIZE) { res2.message = `The file "${node.name}" with size ${node.size / 1e6}MB is greater than maximum ${MAX_FILE_SIZE / 1e6}MB.`; return res2; |
