]> git.p6c8.net - jirafeau/jirafeau.git/commitdiff
Show the disallowed extensions list only when the selected file matches
authorTehPeGaSuS <25697531+TehPeGaSuS@users.noreply.github.com>
Sun, 25 Oct 2026 22:48:51 +0000 (23:48 +0100)
committerTehPeGaSuS <25697531+TehPeGaSuS@users.noreply.github.com>
Sun, 25 Oct 2026 22:48:51 +0000 (23:48 +0100)
index.php
lib/functions.js.php

index 438486790e9e3db985a6824135f41ed7aec1146d..454bc5209e2721de4b5d7dea694d7f67e386791e 100644 (file)
--- a/index.php
+++ b/index.php
@@ -187,7 +187,8 @@ if ($cfg['maximal_upload_size'] >= 1024) {
     echo '<p class="config"></p>';
 }
 if (!empty($cfg['disallowed_extensions'])) {
-    echo '<p class="config">' . t('EXT_LIM') . ' ' . implode(', ', jirafeau_disallowed_extensions($cfg)) . '</p>';
+    // only shown when the selected file matches, see control_selected_file_extension()
+    echo '<p id="disallowed_extensions" class="config" style="display: none">' . t('EXT_LIM') . ' ' . implode(', ', jirafeau_disallowed_extensions($cfg)) . '</p>';
 }
 ?>
 
index 65febf178f49b9b81ecb1904cc925f851b12bf45..355cbe75f14e4d5ab82500d6f00526d878fe9cf6 100644 (file)
@@ -356,6 +356,8 @@ function control_selected_file_size(max_size, error_str)
 // just warns the user before they submit a doomed upload.
 function control_selected_file_extension(disallowed_extensions, error_str)
 {
+    if (disallowed_extensions.length === 0)
+        return;
     f_name = document.getElementById('file_select').files[0].name.replace(/[\s.]+$/, '').toLowerCase();
     // suffix match so that compound extensions such as 'tar.gz' work too
     if (disallowed_extensions.some(function (ext) { return f_name.endsWith('.' + ext); }))
@@ -369,7 +371,10 @@ function control_selected_file_extension(disallowed_extensions, error_str)
         // keep the button visible but disabled so the user sees it is forbidden
         document.getElementById('send').style.display = 'block';
         document.getElementById('send').disabled = true;
+        document.getElementById('disallowed_extensions').style.display = 'block';
     }
+    else
+        document.getElementById('disallowed_extensions').style.display = 'none';
 }
 
 function XHRErrorHandler(e)

patrick-canterino.de