extension filters unlock

frdel committed Jan 19, 2025 at 20:51 UTC 665b6c5f2710835bd8b3903a13d5123ac89b03e0
3 files changed +7 -19
python/api/upload.py
+3 -2
@@ -23,5 +23,6 @@ class UploadFile(ApiHandler):
23
24
25 def allowed_file(self,filename):
26 - ALLOWED_EXTENSIONS = {"png", "jpg", "jpeg", "txt", "pdf", "csv", "html", "json", "md"}
27 - return "." in filename and filename.rsplit(".", 1)[1].lower() in ALLOWED_EXTENSIONS
\ No newline at end of file
26 + return True
27 + # ALLOWED_EXTENSIONS = {"png", "jpg", "jpeg", "txt", "pdf", "csv", "html", "json", "md"}
28 + # return "." in filename and filename.rsplit(".", 1)[1].lower() in ALLOWED_EXTENSIONS
\ No newline at end of file
webui/index.html
+2 -12
@@ -223,17 +223,10 @@
223
224 handleFileUpload(event) {
225 const files = event.target.files;
226 - //if (files.length + this.attachments.length > 4) {
227 - // alert('Maximum 4 attachments allowed');
228 - // return;
229 - //}
226
227 Array.from(files).forEach(file => {
228 const ext = file.name.split('.').pop().toLowerCase();
233 - const allowedExts = new Set(['jpg', 'jpeg', 'png', 'bmp', 'md', 'py', 'js', 'sh',
234 - 'html', 'css', 'pdf', 'txt', 'csv', 'json']);
235 -
236 - //if (allowedExts.has(ext)) {
229 +
230 const isImage = ['jpg', 'jpeg', 'png', 'bmp'].includes(ext);
231
232 if (isImage) {
@@ -260,7 +253,6 @@
253 });
254 this.hasAttachments = true;
255 }
263 - //}
256 });
257 }
258 }">
@@ -296,9 +288,7 @@
288 d="M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5c0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6h-1.5z" />
289 </svg>
290 </label>
299 - <input type="file" id="file-input"
300 - accept=".png, .jpg, .jpeg, .txt, .pdf, .csv, .html, .json, .md, .py, .js, .sh, .css"
301 - multiple style="display: none" @change="handleFileUpload($event)">
291 + <input type="file" id="file-input" accept="*" multiple style="display: none" @change="handleFileUpload($event)">
292
293 <div x-show="showTooltip" class="tooltip">
294 Add attachments to the message
webui/index.js
+2 -5
@@ -916,10 +916,7 @@ document.addEventListener('DOMContentLoaded', () => {
916 function handleFiles(files, inputAD) {
917 Array.from(files).forEach(file => {
918 const ext = file.name.split('.').pop().toLowerCase();
919 - const allowedExts = new Set(['jpg', 'jpeg', 'png', 'bmp', 'md', 'py', 'js', 'sh',
920 - 'html', 'css', 'pdf', 'txt', 'csv', 'json']);
921 -
922 - if (allowedExts.has(ext)) {
919 +
920 const isImage = ['jpg', 'jpeg', 'png', 'bmp'].includes(ext);
921
922 if (isImage) {
@@ -944,7 +941,7 @@ function handleFiles(files, inputAD) {
941 });
942 inputAD.hasAttachments = true;
943 }
947 - }
944 +
945 });
946 }
947