]> git.p6c8.net - jirafeau/jirafeau.git/commitdiff
Merge branch 'next-release' into 'next-release'
authorPatrick Canterino <patrick@patrick-canterino.de>
Wed, 12 Aug 2026 11:25:44 +0000 (13:25 +0200)
committerPatrick Canterino <patrick@patrick-canterino.de>
Wed, 12 Aug 2026 11:25:44 +0000 (13:25 +0200)
Promoting MR 35 to Next-Rrelease Except the Password Hashing that is Already Implemented

See merge request jirafeau/Jirafeau!37

1  2 
f.php
index.php
script.php

diff --combined f.php
index 870b4bdd8aa28b400d92f668c83ca784f1d7cfe6,b13e03b8144679e4b0e6e041268379b46c1ed94a..352359668f61c4cf7b4b1a06f1d019df7ca77ed5
--- 1/f.php
--- 2/f.php
+++ b/f.php
@@@ -36,7 -36,7 +36,7 @@@ if (!isset($_GET['h']) || empty($_GET['
  
  $link_name = $_GET['h'];
  
- if (!preg_match('/[0-9a-zA-Z_-]+$/', $link_name)) {
+ if (!preg_match('/^[0-9a-zA-Z_-]+$/', $link_name)) {
      require(JIRAFEAU_ROOT.'lib/template/header.php');
      echo '<div class="error"><p>' . t('FILE_404') . '</p></div>';
      require(JIRAFEAU_ROOT.'lib/template/footer.php');
@@@ -82,7 -82,7 +82,7 @@@ if (!file_exists(VAR_FILES . $p . $link
      exit;
  }
  
- if (!empty($delete_code) && $delete_code == $link['link_code']) {
+ if (!empty($delete_code) && hash_equals((string) $link['link_code'], (string) $delete_code)) {
      require(JIRAFEAU_ROOT.'lib/template/header.php');
      if (isset($_POST['do_delete'])) {
          jirafeau_delete_link($link_name);
@@@ -171,9 -171,7 +171,9 @@@ if (!empty($link['key'])) 
          require(JIRAFEAU_ROOT.'lib/template/footer.php');
          exit;
      } else {
 -        if (hash_equals($link['key'], md5($_POST['key']))) {
 +        if (strpos($link['key'], '[SHA256]') == 0 && hash_equals(substr($link['key'], 8), hash('sha256', $_POST['key']))) {
 +            $password_challenged = true;
 +        } elseif (hash_equals($link['key'], md5($_POST['key']))) {
              $password_challenged = true;
          } else {
              sleep(2);
diff --combined index.php
index 82b3c8c9e7959fddd43f1ecee2300cb4a71953a8,74c68a059aeb79e83cb90076b7c13062475f37c2..d60cb1809dfebb56b6e8f8295ca6b054d6e43269
+++ b/index.php
@@@ -156,16 -156,14 +156,16 @@@ if ($cfg['download_password_requirement
      echo '<input type="hidden" name="key" id="input_key" value="' . $download_pass .'"/>';
  } else {
      echo '<tr><td><label for="input_key">' . t('PSW') . ':' . '</label></td>';
 -    echo '<td><input type="password" name="key" id="input_key" autocomplete = "new-password"';
 +    echo '<td class="passwordcolumn"><input type="password" name="key" id="input_key" autocomplete = "new-password"';
      if ($cfg['download_password_policy'] === 'regex') {
-         echo ' pattern="' . substr($cfg['download_password_policy_regex'], 1, strlen($cfg['download_password_policy_regex']) - 2) . '"'; //remove php delimiters
+         echo ' pattern="' . jirafeau_escape(substr($cfg['download_password_policy_regex'], 1, strlen($cfg['download_password_policy_regex']) - 2)) . '"'; //remove php delimiters
      }
      if ($cfg['download_password_requirement'] === 'required') {
          echo ' required';
      }
 -    echo '/></td></tr>';
 +    echo ' /> <button data-toggle="false" type="button" id="show_password">
 +    </button>';
 +    echo '</td></tr>';
  }?>
          <tr>
          <td><label for="select_time"><?php echo t('TIME_LIM') . ':'; ?></label></td>
@@@ -208,20 -206,6 +208,20 @@@ if ($cfg['maximal_upload_size'] >= 1024
  
  <script type="text/javascript" lang="Javascript">
  // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
 +    // ICONS in SVG
 +    const EYE_OPEN = `<svg width="20" height="20" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" aria-hidden="true" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
 + <path d="m1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" stroke-width="1.7604"/>
 + <circle cx="12" cy="12" r="3"/>
 + <path d="m2.9757 2.7901 18.56 18.546" display="none" fill="none" stroke="#000" stroke-width="1.7604"/>
 +</svg>`;
 +    const EYE_CLOSE = `<svg width="20" height="20" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" aria-hidden="true" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
 + <path d="m1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" stroke-width="1.7604"/>
 + <circle cx="12" cy="12" r="3"/>
 + <path d="m2.9757 2.7901 18.56 18.546" fill="none" stroke="#000" stroke-width="1.7604"/>
 +</svg>`;
 +
 +
 +
      document.getElementById('error_pop').style.display = 'none';
      document.getElementById('uploading').style.display = 'none';
      document.getElementById('upload_finished').style.display = 'none';
@@@ -241,22 -225,5 +241,22 @@@ if ($max_size > 0) 
      addCopyListener('delete_link_button', 'delete_link');
      addTextCopyListener('password_copy_button', 'output_key');
  // @license-end
 +// show password toggle
 +    document.getElementById('show_password').innerHTML = EYE_OPEN;
 +    document.getElementById('show_password')?.addEventListener('click', function() {
 +        const pwd = document.getElementById('input_key');
 +        const show_password = pwd.type === 'text';
 +        const next_show_password_toggle_value  = !show_password;
 +        if (next_show_password_toggle_value) {
 +            pwd.type = 'text';
 +            document.getElementById('show_password').setAttribute('data-show-enabled', true);
 +            // symbol eye strikethrough
 +            document.getElementById('show_password').innerHTML = EYE_CLOSE;
 +        } else {
 +            pwd.type = 'password';
 +            // symbol eye 
 +            document.getElementById('show_password').innerHTML = EYE_OPEN;
 +        }
 +    });
  </script>
  <?php require(JIRAFEAU_ROOT . 'lib/template/footer.php'); ?>
diff --combined script.php
index 301ebe8cb088e83e6d9774bdc852d36811e10c68,cc37c41351569b620b3767f9c3309af1f6345b6a..2fc297f3412302a0933ef91d3d85f82560c49df9
@@@ -163,7 -163,7 +163,7 @@@ if (isset($_FILES['file']) && is_writab
          $d = $_GET['d'];
      }
  
-     if (!preg_match('/[0-9a-zA-Z_-]+$/', $link_name)) {
+     if (!preg_match('/^[0-9a-zA-Z_-]+$/', $link_name)) {
          echo 'Error 7';
          exit;
      }
          echo 'Error 9';
          exit;
      }
 -    if (strlen($link['key']) > 0 && md5($key) != $link['key']) {
 +    if (strlen($link['key']) > 0 && hash('sha256', $key) != $link['key']) {
          sleep(2);
          echo 'Error 10';
          exit;

patrick-canterino.de