From 05759f264cd57bd1efc6c20844edcc35fd39bab5 Mon Sep 17 00:00:00 2001 From: Cerdic <cedric@yterium.com> Date: Sat, 6 Jul 2013 14:29:51 +0000 Subject: [PATCH] =?UTF-8?q?Report=20de=20r20707=20:=20une=20constante=20?= =?UTF-8?q?=5FINC=5FDISTANT=5FMAX=5FSIZE=20pour=20fixer=20la=20taille=20ma?= =?UTF-8?q?xi=20des=20donnes=20r=C3=A9cup=C3=A9rees=20par=20recuperer=5Fpa?= =?UTF-8?q?ge()=20(initialisee=20a=202Mo,=20et=20non=20plus=201Mo,=20infla?= =?UTF-8?q?tion=20oblige)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecrire/inc/distant.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ecrire/inc/distant.php b/ecrire/inc/distant.php index 52def2ffa4..acbfc32947 100644 --- a/ecrire/inc/distant.php +++ b/ecrire/inc/distant.php @@ -20,6 +20,7 @@ if (!defined('_ECRIRE_INC_VERSION')) return; if (!defined('_INC_DISTANT_VERSION_HTTP')) define('_INC_DISTANT_VERSION_HTTP', "HTTP/1.0"); if (!defined('_INC_DISTANT_CONTENT_ENCODING')) define('_INC_DISTANT_CONTENT_ENCODING', "gzip"); if (!defined('_INC_DISTANT_USER_AGENT')) define('_INC_DISTANT_USER_AGENT', 'SPIP-' . $GLOBALS['spip_version_affichee'] . " (" . $GLOBALS['home_server'] . ")"); +if (!defined('_INC_DISTANT_MAX_SIZE')) define('_INC_DISTANT_MAX_SIZE',2097152); define('_REGEXP_COPIE_LOCALE', ',' . preg_replace('@^https?:@', 'https?:', $GLOBALS['meta']['adresse_site']) @@ -253,7 +254,7 @@ function recuperer_url($url, $options = array()){ if ($options['methode']=="HEAD") $options['taille_max'] = 0; if (is_null($options['taille_max'])) - $options['taille_max'] = $copy ? _COPIE_LOCALE_MAX_SIZE : 1048576; + $options['taille_max'] = $copy ? _COPIE_LOCALE_MAX_SIZE : _INC_DISTANT_MAX_SIZE; if (!empty($options['datas'])) { $options['methode'] = 'POST'; @@ -563,7 +564,7 @@ function recuperer_lapage($url, $trans = false, $get = 'GET', $taille_max = 1048 * int taille du fichier si argument fichier fourni * string contenu de la resource */ -function recuperer_body($handle, $taille_max = 1048576, $fichier = ''){ +function recuperer_body($handle, $taille_max = _INC_DISTANT_MAX_SIZE, $fichier = ''){ $taille = 0; $result = ''; $fp = false; @@ -881,18 +882,18 @@ function recuperer_infos_distantes($source, $max = 0, $charger_si_petite_image = // Echec avec HEAD, on tente avec GET if (!$a AND !$max){ spip_log("tenter GET $source"); - $a = recuperer_infos_distantes($source, 1024*1024); + $a = recuperer_infos_distantes($source, _INC_DISTANT_MAX_SIZE); } // S'il s'agit d'une image pas trop grosse ou d'un fichier html, on va aller // recharger le document en GET et recuperer des donnees supplementaires... if (preg_match(',^image/(jpeg|gif|png|swf),', $mime_type)){ if ($max==0 - AND $a['taille']<1024*1024 + AND $a['taille']<_INC_DISTANT_MAX_SIZE AND (strpos($GLOBALS['meta']['formats_graphiques'], $a['extension'])!==false) AND $charger_si_petite_image ){ - $a = recuperer_infos_distantes($source, 1024*1024); + $a = recuperer_infos_distantes($source, _INC_DISTANT_MAX_SIZE); } else if ($a['body']){ $a['fichier'] = _DIR_RACINE . nom_fichier_copie_locale($source, $a['extension']); @@ -915,7 +916,7 @@ function recuperer_infos_distantes($source, $max = 0, $charger_si_petite_image = if ($mime_type=='text/html'){ include_spip('inc/filtres'); - $page = recuperer_page($source, true, false, 1024*1024); + $page = recuperer_page($source, true, false, _INC_DISTANT_MAX_SIZE); if (preg_match(',<title>(.*?)</title>,ims', $page, $regs)) $a['titre'] = corriger_caracteres(trim($regs[1])); if (!$a['taille']) $a['taille'] = strlen($page); # a peu pres -- GitLab