]> git.p6c8.net - jirafeau.git/blobdiff - lib/functions.js.php
[BUGFIX] Limit upload chunk size to a reasonable value
[jirafeau.git] / lib / functions.js.php
index 71ce17ba0dafdc18a92ae8a022d98677f9f7d6f8..c1a81d8045c16bc2ecbb5c2346d3f2188404f676 100644 (file)
@@ -182,16 +182,17 @@ function show_link (reference, delete_code, crypt_key, date)
         }
 
         // Test if content can be previewed
-         type = document.getElementById('file_select').files[0].type;
-         if (type.indexOf("image") > -1 ||
-             type.indexOf("audio") > -1 ||
-             type.indexOf("text") > -1 ||
-             type.indexOf("video") > -1)
-         {
+        type = document.getElementById('file_select').files[0].type;
+        if ((type.startsWith('image/')
+                || type.startsWith('audio')
+                || type.startsWith('text/plain')
+                || type.startsWith('video/'))
+            && !type.includes('image/svg+xml'))
+        {
             document.getElementById('preview_link').href = preview_link_href;
             document.getElementById('preview_link_text').innerHTML = web_root + preview_link_href;
             document.getElementById('upload_finished_preview').style.display = '';
-         }
+        }
     }
 
     // Direct download link
@@ -320,6 +321,11 @@ function add_time_string_to_date(d, time)
         d.setSeconds (d.getSeconds() + 604800);
         return true;
     }
+    if (time == 'fortnight')
+    {
+        d.setSeconds (d.getSeconds() + 1209600);
+        return true;
+    }
     if (time == 'month')
     {
                d.setSeconds (d.getSeconds() + 2592000);
@@ -590,14 +596,14 @@ function async_upload_end (code)
     req.send (form);
 }
 
-function upload (max_size)
+function upload (max_chunk_size)
 {
     var one_time_checkbox = document.getElementById('one_time_download');
     var one_time = one_time_checkbox !== null ? one_time_checkbox.checked : false;
     if (check_html5_file_api ())
     {
         async_upload_start (
-            max_size,
+            max_chunk_size,
             document.getElementById('file_select').files[0],
             document.getElementById('select_time').value,
             document.getElementById('input_key').value,

patrick-canterino.de