diff -ru ./ecrire/inc_charsets.php3 ../SPIP-v1-8-3/ecrire/inc_charsets.php3
--- ./ecrire/inc_charsets.php3 2005-08-01 18:36:57.000000000 +0200
+++ ../SPIP-v1-8-3/ecrire/inc_charsets.php3 2006-02-11 15:13:28.000000000 +0100
@@ -2138,6 +2138,8 @@
if ($charset == 'AUTO')
$charset = lire_meta('charset');
+ $charset = strtolower($charset);
+
switch ($charset) {
case 'utf-8':
return utf_8_to_unicode($texte);
diff -ru ./ecrire/inc_db_mysql.php3 ../SPIP-v1-8-3/ecrire/inc_db_mysql.php3
--- ./ecrire/inc_db_mysql.php3 2005-08-25 21:58:56.000000000 +0200
+++ ../SPIP-v1-8-3/ecrire/inc_db_mysql.php3 2006-02-11 15:13:28.000000000 +0100
@@ -237,7 +237,7 @@
// IN (...) est limite a 255 elements, d'ou cette fonction assistante
//
function calcul_mysql_in($val, $valeurs, $not='') {
- if (!$valeurs) return '0=0';
+ if (!$valeurs) return ($not ? "0=0" : '0=1');
$n = $i = 0;
$in_sql ="";
diff -ru ./ecrire/inc_lang.php3 ../SPIP-v1-8-3/ecrire/inc_lang.php3
--- ./ecrire/inc_lang.php3 2005-11-04 21:23:10.000000000 +0100
+++ ../SPIP-v1-8-3/ecrire/inc_lang.php3 2006-02-11 11:29:24.000000000 +0100
@@ -318,7 +318,7 @@
'su' => "Sundanese",
'sv' => "svenska",
'sw' => "Kiswahili",
- 'ta' => "தமிழ் - tamil",
+ 'ta' => "தமிழ்", // Tamil
'te' => "Telugu",
'tg' => "Tajik",
'th' => "ไทย",
diff -ru ./ecrire/inc_layer.php3 ../SPIP-v1-8-3/ecrire/inc_layer.php3
--- ./ecrire/inc_layer.php3 2005-05-01 21:00:55.000000000 +0200
+++ ../SPIP-v1-8-3/ecrire/inc_layer.php3 2006-03-10 01:11:12.000000000 +0100
@@ -110,9 +110,9 @@
// Tests sur le nom du butineur
//
function verif_butineur() {
- global $HTTP_USER_AGENT, $browser_name, $browser_version;
+ global $browser_name, $browser_version;
global $browser_description, $browser_rev, $browser_layer, $browser_barre;
- ereg("^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$", $HTTP_USER_AGENT, $match);
+ ereg("^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$", $_SERVER['HTTP_USER_AGENT'], $match);
$browser_name = $match[1];
$browser_version = $match[2];
$browser_description = $match[3];
@@ -137,6 +137,7 @@
$browser_name = "Safari";
$browser_version = $match[1];
$browser_layer = http_script('', _DIR_INCLUDE . 'layer.js','');
+ $browser_barre = ($browser_version >= 5.0);
}
else if (eregi("mozilla", $browser_name) AND $browser_version >= 5) {
$browser_layer = http_script('', _DIR_INCLUDE . 'layer.js','');
diff -ru ./ecrire/inc_logos.php3 ../SPIP-v1-8-3/ecrire/inc_logos.php3
--- ./ecrire/inc_logos.php3 2005-10-26 21:10:34.000000000 +0200
+++ ../SPIP-v1-8-3/ecrire/inc_logos.php3 2006-03-10 01:10:46.000000000 +0100
@@ -343,8 +343,21 @@
// Recopie de l'image d'origine avec adaptation de la taille
$ok = false;
- if (($process == 'gd2') AND function_exists('ImageCopyResampled'))
+ if (($process == 'gd2') AND function_exists('ImageCopyResampled')) {
+ if ($format == "gif") {
+ // Si un GIF est transparent,
+ // fabriquer un PNG transparent
+ $transp = imagecolortransparent($srcImage);
+ if ($transp > 0) $destFormat = "png";
+ }
+ if ($destFormat == "png") {
+ // Conserver la transparence
+ if (function_exists("imageAntiAlias")) imageAntiAlias($destImage,true);
+ @imagealphablending($destImage, false);
+ @imagesavealpha($destImage,true);
+ }
$ok = @ImageCopyResampled($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
+ }
if (!$ok)
$ok = ImageCopyResized($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
diff -ru ./ecrire/inc_majbase.php3 ../SPIP-v1-8-3/ecrire/inc_majbase.php3
--- ./ecrire/inc_majbase.php3 2005-08-25 11:16:47.000000000 +0200
+++ ../SPIP-v1-8-3/ecrire/inc_majbase.php3 2006-02-11 16:11:35.000000000 +0100
@@ -971,14 +971,12 @@
maj_version(1.813);
}
- // URLs propres auteurs (et prevoir les sites, sait-on jamais)
+ // URLs propres auteurs
if ($version_installee < 1.814) {
- foreach (array('auteurs', 'syndic') as $objets) {
- spip_query("ALTER TABLE spip_$objets
- ADD url_propre VARCHAR(255) NOT NULL");
- spip_query("ALTER TABLE spip_$objets
- ADD INDEX url_propre (url_propre)");
- }
+ spip_query("ALTER TABLE spip_auteurs
+ ADD url_propre VARCHAR(255) NOT NULL");
+ spip_query("ALTER TABLE spip_auteurs
+ ADD INDEX url_propre (url_propre)");
maj_version(1.814);
}
@@ -1046,6 +1044,20 @@
maj_version(1.822);
}
+ // URLs propres des sites (sait-on jamais)
+ // + oubli des KEY url_propre sur les auteurs si installation neuve
+ if ($version_installee < 1.830) {
+ spip_query("ALTER TABLE spip_syndic
+ ADD url_propre VARCHAR(255) NOT NULL");
+ spip_query("ALTER TABLE spip_syndic
+ ADD INDEX url_propre (url_propre)");
+ spip_query("ALTER TABLE spip_auteurs
+ ADD url_propre VARCHAR(255) NOT NULL");
+ spip_query("ALTER TABLE spip_auteurs
+ ADD INDEX url_propre (url_propre)");
+ maj_version(1.830);
+ }
+
return true;
}
diff -ru ./ecrire/inc.php3 ../SPIP-v1-8-3/ecrire/inc.php3
--- ./ecrire/inc.php3 2005-06-07 15:38:04.000000000 +0200
+++ ../SPIP-v1-8-3/ecrire/inc.php3 2006-02-11 16:11:35.000000000 +0100
@@ -28,8 +28,7 @@
include_ecrire('inc_admin.php3');
-//
-// Preferences de presentation
+//// Preferences de presentation
//
if ($spip_lang_ecrire = $GLOBALS['_COOKIE']['spip_lang_ecrire']
diff -ru ./ecrire/inc_presentation.php3 ../SPIP-v1-8-3/ecrire/inc_presentation.php3
--- ./ecrire/inc_presentation.php3 2005-09-04 16:24:59.000000000 +0200
+++ ../SPIP-v1-8-3/ecrire/inc_presentation.php3 2006-02-11 18:57:20.000000000 +0100
@@ -1337,6 +1337,7 @@
if ($spip_display == 4) echo "
";
while($row = spip_fetch_array($request)) {
+ $row = safehtml_sur_row($row);
$id_forum=$row['id_forum'];
$id_parent=$row['id_parent'];
$id_rubrique=$row['id_rubrique'];
diff -ru ./ecrire/inc_rss.php3 ../SPIP-v1-8-3/ecrire/inc_rss.php3
--- ./ecrire/inc_rss.php3 2005-07-26 14:29:24.000000000 +0200
+++ ../SPIP-v1-8-3/ecrire/inc_rss.php3 2006-02-09 16:21:03.000000000 +0100
@@ -193,6 +193,7 @@
// Suivi des forums
function rss_suivi_forums($a, $query_forum='', $lien_moderation=false) {
+ $rss = array();
include_ecrire("inc_forum.php3");
$result_forum = spip_query("
@@ -302,6 +303,7 @@
}
function rss_articles($critere) {
+ $rss = array();
$s = spip_query("SELECT * FROM spip_articles WHERE $critere
ORDER BY date DESC LIMIT 0,10");
while ($t = spip_fetch_array($s)) {
@@ -330,6 +332,7 @@
function rss_breves($critere) {
+ $rss = array();
$s = spip_query("SELECT * FROM spip_breves WHERE $critere
ORDER BY date_heure DESC LIMIT 0,10");
while ($t = spip_fetch_array($s)) {
@@ -350,6 +353,7 @@
function rss_sites($critere) {
+ $rss = array();
$s = spip_query("SELECT * FROM spip_syndic WHERE $critere
ORDER BY date DESC LIMIT 0,10");
while ($t = spip_fetch_array($s)) {
diff -ru ./ecrire/inc_serialbase.php3 ../SPIP-v1-8-3/ecrire/inc_serialbase.php3
--- ./ecrire/inc_serialbase.php3 2005-08-25 11:16:47.000000000 +0200
+++ ../SPIP-v1-8-3/ecrire/inc_serialbase.php3 2006-02-11 16:11:35.000000000 +0100
@@ -93,7 +93,8 @@
"KEY statut" => "statut",
"KEY lang" => "lang",
"KEY idx" => "idx",
- "KEY en_ligne" => "en_ligne");
+ "KEY en_ligne" => "en_ligne",
+ "KEY url_propre" => "url_propre");
$spip_breves = array(
"id_breve" => "bigint(21) NOT NULL",
@@ -242,6 +243,7 @@
"nom_site" => "blob NOT NULL",
"url_site" => "blob NOT NULL",
"url_syndic" => "blob NOT NULL",
+ "url_propre" => "VARCHAR(255) NOT NULL",
"descriptif" => "blob NOT NULL",
"idx" => "ENUM('', '1', 'non', 'oui', 'idx') DEFAULT '' NOT NULL",
"maj" => "TIMESTAMP",
@@ -261,7 +263,8 @@
"KEY id_rubrique" => "id_rubrique",
"KEY id_secteur" => "id_secteur",
"KEY idx" => "idx",
- "KEY statut" => "statut, date_syndic");
+ "KEY statut" => "statut, date_syndic",
+ "KEY url_propre" => "url_propre");
$spip_syndic_articles = array(
"id_syndic_article" => "bigint(21) NOT NULL",
diff -ru ./ecrire/inc_signatures.php3 ../SPIP-v1-8-3/ecrire/inc_signatures.php3
--- ./ecrire/inc_signatures.php3 2005-07-15 14:45:05.000000000 +0200
+++ ../SPIP-v1-8-3/ecrire/inc_signatures.php3 2006-02-11 18:57:20.000000000 +0100
@@ -28,6 +28,7 @@
" LIMIT " . ($debut ? "$debut," : "") . $limit);
while($row=spip_fetch_array($request)){
+ $row = safehtml_sur_row($row);
$id_signature = $row['id_signature'];
$id_article = $row['id_article'];
$date_time = $row['date_time'];
diff -ru ./ecrire/inc_sites.php3 ../SPIP-v1-8-3/ecrire/inc_sites.php3
--- ./ecrire/inc_sites.php3 2005-08-23 19:16:10.000000000 +0200
+++ ../SPIP-v1-8-3/ecrire/inc_sites.php3 2006-02-11 19:27:00.000000000 +0100
@@ -325,7 +325,7 @@
// Cherchons quand meme un backend
include_ecrire('feedfinder.php');
$feeds = get_feed_from_url($url, $texte);
- if (count($feeds>1)) {
+ if (count($feeds)>1) {
spip_log("feedfinder.php :\n".join("\n", $feeds));
$result['url_syndic'] = "select: ".join(' ',$feeds);
} else
@@ -902,6 +902,7 @@
$table = '';
while ($row = spip_fetch_array($result)) {
+ $row = safehtml_sur_row($row);
$vals = '';
$id_syndic_article=$row["id_syndic_article"];
diff -ru ./ecrire/inc_suivi_revisions.php ../SPIP-v1-8-3/ecrire/inc_suivi_revisions.php
--- ./ecrire/inc_suivi_revisions.php 2005-06-07 23:12:24.000000000 +0200
+++ ../SPIP-v1-8-3/ecrire/inc_suivi_revisions.php 2006-02-10 22:17:06.000000000 +0100
@@ -45,9 +45,11 @@
$req_where = " AND articles.statut IN ('prop','publie')";
}
- if (strlen($lang) > 0) $req_where .= " AND articles.lang='$lang'";
+ if (strlen($lang) > 0)
+ $req_where .= " AND articles.lang='".addslashes($lang)."'";
- if ($id_secteur > 0) $req_where .= " AND articles.id_secteur = $id_secteur";
+ if ($id_secteur > 0)
+ $req_where .= " AND articles.id_secteur = ".intval($id_secteur);
$query = "
SELECT versions.*, articles.statut, articles.titre
diff -ru ./ecrire/inc_texte.php3 ../SPIP-v1-8-3/ecrire/inc_texte.php3
--- ./ecrire/inc_texte.php3 2005-10-26 21:10:34.000000000 +0200
+++ ../SPIP-v1-8-3/ecrire/inc_texte.php3 2006-02-25 08:46:12.000000000 +0100
@@ -18,18 +18,21 @@
include_ecrire("inc_filtres.php3");
+
//
-// Initialisation de quelques variables globales
-// (on peut les modifier globalement dans mes_fonctions.php3,
-// OU individuellement pour chaque type de page dans article.php3,
-// rubrique.php3, etc. cf doc...)
+// Gerer les variables de personnalisation, qui peuvent provenir
+// des fichiers d'appel, en verifiant qu'elles n'ont pas ete passees
+// par le visiteur (sinon, pas de cache)
//
-function tester_variable($nom_var, $val){
- if (!isset($GLOBALS[$nom_var])) {
- $GLOBALS[$nom_var] = $val;
- return false;
- }
- return true;
+function tester_variable($var, $val){
+ if (!isset($GLOBALS[$var]))
+ $GLOBALS[$var] = $val;
+
+ if (
+ $_REQUEST[$var] !== NULL
+ AND $GLOBALS[$var] == $_REQUEST[$var]
+ )
+ die ("tester_variable: $var interdite");
}
tester_variable('debut_intertitre', "\n
");
@@ -384,6 +387,53 @@
return $source;
}
+// Securite : utiliser SafeHTML s'il est present dans ecrire/safehtml/
+function safehtml($t) {
+ static $process, $test;
+
+ # attention safehtml nettoie deux ou trois caracteres de plus. A voir
+ if (strpos($t,'<')===false)
+ return str_replace("\x00", '', $t);
+
+ if (!$test) {
+ define('XML_HTMLSAX3', _DIR_INCLUDE."safehtml/classes/");
+ if (@file_exists(XML_HTMLSAX3.'safehtml.php')) {
+ include_local(XML_HTMLSAX3.'safehtml.php');
+ $process = new safehtml();
+ }
+ if ($process)
+ $test = 1; # ok
+ else
+ $test = -1; # se rabattre sur interdire_scripts
+ }
+
+ if ($test > 0) {
+ # reset ($process->clear() ne vide que _xhtml...),
+ # on doit pouvoir programmer ca plus propremement
+ $process->_counter = array();
+ $process->_stack = array();
+ $process->_dcCounter = array();
+ $process->_dcStack = array();
+ $process->_listScope = 0;
+ $process->_liStack = array();
+# $process->parse(''); # cas particulier ?
+ $process->clear();
+ $t = $process->parse($t);
+ }
+
+ return interdire_scripts($t); # gere le < ?php > en plus
+}
+
+// Passer safehtml sur les rows de l'espace privé
+function safehtml_sur_row($row) {
+ $champs_surs = array(
+ 'date', 'date_heure', 'statut', 'ip', 'url_article', 'maj', 'idx',
+ 'parametres_forum');
+ foreach($row as $champ => $valeur)
+ if (!in_array(strtolower($champ), $champs_surs) AND !preg_match(',^id_,', $champ))
+ $row[$champ] = safehtml($valeur);
+ return $row;
+}
// Correction typographique francaise
function typo_fr($letexte) {
diff -ru ./ecrire/inc_version.php3 ../SPIP-v1-8-3/ecrire/inc_version.php3
--- ./ecrire/inc_version.php3 2006-02-04 15:43:01.000000000 +0100
+++ ../SPIP-v1-8-3/ecrire/inc_version.php3 2006-03-10 23:26:33.000000000 +0100
@@ -64,6 +64,9 @@
}
+// Masquer les warning
+error_reporting(E_ALL ^ E_NOTICE);
+
// *********** traiter les variables ************
// Recuperer les superglobales $_GET si non definies
@@ -79,35 +82,47 @@
$GLOBALS[$http_table_vars] = & $GLOBALS[$_table];
}
+//
+// Securite
+//
-// Magic quotes : on n'en veut pas sur la base,
-// et on nettoie les GET/POST/COOKIE le cas echeant
-function magic_unquote($_table) {
-
- // Certains hebergeurs n'activent pas $GLOBALS['GLOBALS']
- if ($_table == 'GLOBALS'
- AND !isset($GLOBALS['GLOBALS']))
- $GLOBALS['GLOBALS'] = &$GLOBALS;
-
- if (is_array($GLOBALS[$_table])) {
- foreach ($GLOBALS[$_table] as $key => $val) {
- if (is_string($val))
- $GLOBALS[$_table][$key] = stripslashes($val);
+// Ne pas se faire manger par un bug php qui laisse passer ?GLOBALS[truc]=toto
+if (isset($_REQUEST['GLOBALS'])) die();
+// Annuler les magic quotes \' sur GET POST COOKIE et GLOBALS ;
+// supprimer aussi les eventuels caracteres nuls %00, qui peuvent tromper
+// la commande file_exists('chemin/vers/fichier/interdit%00truc_normal')
+function spip_desinfecte(&$t) {
+ static $magic_quotes;
+ if (!isset($magic_quotes))
+ $magic_quotes = @get_magic_quotes_gpc();
+
+ if (is_array($t)) {
+ foreach ($t as $key => $val) {
+ if (!is_array($val)
+ OR !isset($t['spip_recursions'])) { # interdire les recursions
+ $t['spip_recursions'] = true;
+ spip_desinfecte($t[$key]);
+ }
}
+ } else {
+ $t = str_replace(chr(0), '', $t);
+ if ($magic_quotes)
+ $t = stripslashes($t);
}
}
-
-@set_magic_quotes_runtime(0);
-if (@get_magic_quotes_gpc()) {
- magic_unquote('_GET');
- magic_unquote('_POST');
- magic_unquote('_COOKIE');
-
+spip_desinfecte($_GET);
+spip_desinfecte($_POST);
+spip_desinfecte($_COOKIE);
# if (@ini_get('register_globals')) // pas fiable
- magic_unquote('GLOBALS');
-}
-
-
+spip_desinfecte($GLOBALS);
+# a la fin supprimer la variable anti-recursion devenue inutile
+# (et meme nuisible, notamment si on teste $_POST)
+unset($_GET['spip_recursions']);
+unset($_POST['spip_recursions']);
+unset($_COOKIE['spip_recursions']);
+unset($GLOBALS['spip_recursions']);
+// Par ailleurs on ne veut pas de magic_quotes au cours de l'execution
+@set_magic_quotes_runtime(0);
// Dirty hack contre le register_globals a 'Off' (PHP 4.1.x)
// A remplacer (un jour!) par une gestion propre des variables admissibles ;-)
@@ -316,9 +331,6 @@
// Produire du TeX ou du MathML ?
$traiter_math = 'tex';
-// Masquer les warning
-error_reporting(E_ALL ^ E_NOTICE);
-
// Variables du compilateur de squelettes
$exceptions_des_tables = array();
@@ -415,10 +427,10 @@
// (utilise pour les modifs de la base de donnees)
// version de la base
-$spip_version = 1.822;
+$spip_version = 1.830;
// version de spip
-$spip_version_affichee = "1.8.2 g";
+$spip_version_affichee = "1.8.3";
// ** Securite **
@@ -525,7 +537,7 @@
}
$f = @fopen($logfile, "ab");
if ($f) {
- fputs($f, $message);
+ fputs($f, htmlspecialchars($message));
fclose($f);
}
if ($rotate) {
@@ -1009,7 +1021,7 @@
// qq fonctions service pour les 2 niveaux
//
function calculer_hierarchie($id_rubrique, $exclure_feuille = false) {
- if (!$id_rubrique)
+ if (!$id_rubrique = intval($id_rubrique))
return '0';
if (!$exclure_feuille)
$hierarchie = ",$id_rubrique";
Only in ../SPIP-v1-8-3/ecrire/lang: ecrire_cs.php3
Only in ../SPIP-v1-8-3/ecrire/lang: public_cs.php3
Only in ../SPIP-v1-8-3/ecrire/lang: spip_cs.php3
diff -ru ./ecrire/naviguer.php3 ../SPIP-v1-8-3/ecrire/naviguer.php3
--- ./ecrire/naviguer.php3 2005-08-19 23:57:18.000000000 +0200
+++ ../SPIP-v1-8-3/ecrire/naviguer.php3 2006-02-25 08:46:12.000000000 +0100
@@ -45,11 +45,17 @@
}
// si c'est une rubrique-secteur contenant des breves, ne deplacer
- // que si $confirme_deplace == 'oui'
-
- if ((spip_num_rows(spip_query("SELECT id_rubrique FROM spip_breves WHERE id_rubrique='$id_rubrique' LIMIT 0,1")) > 0)
- AND ($confirme_deplace != 'oui')) {
- $id_parent = 0;
+ // que si $confirme_deplace == 'oui', et changer l'id_rubrique des
+ // breves en question
+ if ($GLOBALS['confirme_deplace'] == 'oui'
+ AND $id_parent > 0) {
+ list($id_secteur) = spip_fetch_array(spip_query(
+ "SELECT id_secteur FROM spip_rubriques
+ WHERE id_rubrique=$id_parent"));
+ if ($id_secteur)
+ spip_query("UPDATE spip_breves
+ SET id_rubrique=$id_secteur
+ WHERE id_rubrique=$id_rubrique");
}
if ($flag_editable) {
@@ -374,7 +380,7 @@
// Les articles syndiques en attente de validation
if ($id_rubrique == 0 AND $connect_statut == '0minirezo' AND $connect_toutes_rubriques) {
- $result = spip_query ("SELECT COUNT(*) AS compte FROM spip_syndic_articles AND statut='dispo'");
+ $result = spip_query ("SELECT COUNT(*) AS compte FROM spip_syndic_articles WHERE statut='dispo'");
if (($row = spip_fetch_array($result)) AND $row['compte'])
echo " ".$row['compte']." "._T('info_liens_syndiques_1')." "._T('info_liens_syndiques_2')."";
}
Only in ../SPIP-v1-8-3/ecrire: safehtml
diff -ru ./ecrire/suivi_revisions.php3 ../SPIP-v1-8-3/ecrire/suivi_revisions.php3
--- ./ecrire/suivi_revisions.php3 2005-06-08 10:28:07.000000000 +0200
+++ ../SPIP-v1-8-3/ecrire/suivi_revisions.php3 2006-02-10 22:17:06.000000000 +0100
@@ -63,7 +63,7 @@
$query_rub = "
SELECT versions.*, articles.statut, articles.titre
FROM spip_versions AS versions, spip_articles AS articles
-WHERE versions.id_article = articles.id_article AND versions.id_version > 1 AND articles.id_secteur=$id_rubrique$req_where LIMIT 0,1";
+WHERE versions.id_article = articles.id_article AND versions.id_version > 1 AND articles.id_secteur=".intval($id_rubrique)."$req_where LIMIT 0,1";
$result_rub = spip_query($query_rub);
if ($id_rubrique == $id_secteur) echo "
$titre";
@@ -80,7 +80,7 @@
$query_lang = "
SELECT versions.*
FROM spip_versions AS versions, spip_articles AS articles
-WHERE versions.id_article = articles.id_article AND versions.id_version > 1 AND articles.lang='$lang' $req_where LIMIT 0,1";
+WHERE versions.id_article = articles.id_article AND versions.id_version > 1 AND articles.lang='".addslashes($lang)."' $req_where LIMIT 0,1";
$result_lang = spip_query($query_lang);
if ($lang == $lang_choisie) echo "