From a9346f55556c4450c9c03adc5e01e4b64dc0d130 Mon Sep 17 00:00:00 2001 From: "Committo,Ergo:sum" <esj@rezo.net> Date: Tue, 28 Apr 2009 15:09:03 +0000 Subject: [PATCH] =?UTF-8?q?Ce=20n'est=20pas=20parce=20que=20certains=20sys?= =?UTF-8?q?t=C3=A8mes=20d'exploitation=20que=20je=20ne=20nommerai=20pas=20?= =?UTF-8?q?pataugent=20avec=20certains=20noms=20de=20fichiers=20qu'il=20fa?= =?UTF-8?q?ut=20consid=C3=A9rer=20[11243]=20comme=20une=20{{fausse=20bonne?= =?UTF-8?q?=20id=C3=A9e}}=20comme=20le=20dit=20[13760].=20Je=20filtre=20le?= =?UTF-8?q?=20cas=20du=20titre=20de=20document=20n'ayant=20pas=20d'extensi?= =?UTF-8?q?on=20qui=20ne=20doit=20en=20effet=20pas=20=C3=AAtre=20utilis?= =?UTF-8?q?=C3=A9=20comme=20nom=20de=20fichier=20du=20{{{Content-Dispositi?= =?UTF-8?q?on}}}=20(et=20encore,=20{{{Makefile}}}=C2=A0est=20notoirement?= =?UTF-8?q?=20recevable),=20mais=20autrement=20je=20restaure=20le=20compor?= =?UTF-8?q?tement=20d'avant=20qui=20est=20une=20fausse=20{{fausse=20bonne?= =?UTF-8?q?=20id=C3=A9e}}},=20autrement=20dit=20une=20vraie=20bonn=C3=A9?= =?UTF-8?q?=20id=C3=A9e.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Par contrecoup, report du renforcement de sécurité su secret du site [13866] dans la branche 2.0. --- ecrire/action/acceder_document.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/ecrire/action/acceder_document.php b/ecrire/action/acceder_document.php index 05f1e34aff..cc4b525246 100644 --- a/ecrire/action/acceder_document.php +++ b/ecrire/action/acceder_document.php @@ -82,16 +82,30 @@ function action_acceder_document_dist() { break; default: - // Content-Type ; pour les images ne pas passer en attachment + header("Content-Type: ". $doc['mime_type']); + + // pour les images ne pas passer en attachment // sinon, lorsqu'on pointe directement sur leur adresse, // le navigateur les downloade au lieu de les afficher - header("Content-Type: ". $doc['mime_type']); if ($doc['inclus']=='non') { - $f = $doc['titre'] ? $doc['titre'] : basename($file); - //header('Content-Type: application/octet-stream'); + + // Si le fichier a un titre avec extension, + // ou si c'est un nom bien connu d'Unix, le prendre + // sinon l'ignorer car certains navigateurs pataugent + + $f = @$doc['titre']; + if (!preg_match('/\.\w+$/', $f) AND $f !== 'Makefile') + $f = basename($file); + header("Content-Disposition: attachment; filename=\"$f\";"); header("Content-Transfer-Encoding: binary"); + + // fix for IE catching or PHP bug issue + header("Pragma: public"); + header("Expires: 0"); // set expiration time + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); + } if ($cl = filesize($file)) -- GitLab