From a6f5953c61c3503f8d99ecd4d5c0eb2f7ea539d2 Mon Sep 17 00:00:00 2001 From: dev Date: Sun, 1 Nov 2026 11:06:20 +0300 Subject: [PATCH] =?UTF-8?q?files:=20=D1=80=D0=B0=D0=B7=D1=80=D0=B5=D1=88?= =?UTF-8?q?=D0=B8=D1=82=D1=8C=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA?= =?UTF-8?q?=D1=83=20html,=20css=20=D0=B8=20js=20=D0=BD=D0=B0=20=D1=84?= =?UTF-8?q?=D0=BE=D1=80=D0=BC=D0=B5=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API.md | 2 +- public/js/index.js | 2 +- server.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/API.md b/API.md index 86171cc..1ab0d10 100644 --- a/API.md +++ b/API.md @@ -584,7 +584,7 @@ MAX_TOTAL_UPLOAD_BYTES = UPLOAD_TOTAL_LIMIT_MB * 1024 * 1024 | `adminUpload` (`server.js:1202`) | файлы проекта | `ADMIN_ALLOWED_EXT`: pdf, doc, docx, txt, md, html, htm, zip, rar, 7z + изображения. `BLOCKED_EXT` блокируется, если расширения нет в списке | | `uploadBackup` (`server.js:2460`) | восстановление | только `\.(?:tar\.gz\|tgz\|gz)$`; пишет во временный каталог `os.tmpdir()/wido-up-XXXX`, **не** в `uploads/` | -`BLOCKED_EXT` (`server.js:1164`) — regexp, запрещающий `html, htm, js, mjs, cjs, svg, xml, json, map, wasm, php*, phtml, asp*, jsp, sh, bat, cmd, cgi, exe, dll, com, msi, scr, hta, vbs, py, r, rb, htaccess`. +`BLOCKED_EXT` (`server.js:1164`) — regexp, запрещающий `svg, xml, json, map, wasm, php*, phtml, asp*, jsp, sh, bat, cmd, cgi, exe, dll, com, msi, scr, hta, vbs, py, r, rb, htaccess`. Веб-файлы (`html`, `htm`, `css`, `js`, `mjs`, `cjs`) разрешены; скачивание отдаёт их как `attachment` (`GET /api/files/:token`), в браузере они не исполняются. ### Эндпоинты и имена полей form-data diff --git a/public/js/index.js b/public/js/index.js index c671a15..6143ebf 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -126,7 +126,7 @@ const DEFAULT_FILE_LIMIT_MB = 50; const DEFAULT_TOTAL_LIMIT_MB = 200; let MAX_FILE_BYTES = DEFAULT_FILE_LIMIT_MB * 1024 * 1024; let MAX_TOTAL_BYTES = DEFAULT_TOTAL_LIMIT_MB * 1024 * 1024; -const BLOCKED_FILE_EXT = /\.(?:html?|js|mjs|cjs|svg|xml|json|map|wasm|php\d?|phtml|asp|aspx|jsp|sh|bat|cmd|cgi|exe|dll|com|msi|scr|hta|vbs|py|r|rb|htaccess)$/i; +const BLOCKED_FILE_EXT = /\.(?:svg|xml|json|map|wasm|php\d?|phtml|asp|aspx|jsp|sh|bat|cmd|cgi|exe|dll|com|msi|scr|hta|vbs|py|r|rb|htaccess)$/i; const MIME_EXT = { 'image/png': '.png', 'image/jpeg': '.jpg', 'image/jpg': '.jpg', 'image/gif': '.gif', 'image/webp': '.webp', 'image/bmp': '.bmp', 'image/avif': '.avif', 'image/heic': '.heic', 'image/heif': '.heif', 'image/svg+xml': '.svg', diff --git a/server.js b/server.js index 63f0dcc..89ac834 100644 --- a/server.js +++ b/server.js @@ -1540,7 +1540,7 @@ function fixFilename(str) { } } -const BLOCKED_EXT = /\.(?:html?|js|mjs|cjs|svg|xml|json|map|wasm|php\d?|phtml|asp|aspx|jsp|sh|bat|cmd|cgi|exe|dll|com|msi|scr|hta|vbs|py|r|rb|htaccess)$/i; +const BLOCKED_EXT = /\.(?:svg|xml|json|map|wasm|php\d?|phtml|asp|aspx|jsp|sh|bat|cmd|cgi|exe|dll|com|msi|scr|hta|vbs|py|r|rb|htaccess)$/i; const ALLOWED_IMAGE_EXT = new Set(['.jpg', '.jpeg', '.png', '.gif', '.webp', '.bmp', '.avif', '.ico', '.heic', '.heif', '.jfif']); const UPLOAD_FILE_LIMIT_MB = Math.max(1, parseInt(process.env.UPLOAD_FILE_LIMIT_MB || '50', 10) || 50); const UPLOAD_TOTAL_LIMIT_MB = Math.max(UPLOAD_FILE_LIMIT_MB, parseInt(process.env.UPLOAD_TOTAL_LIMIT_MB || '200', 10) || 200);