From 4378575a3759652032c620c90d2c17bec2153bb9 Mon Sep 17 00:00:00 2001
From: Cerdic <cedric@yterium.com>
Date: Sat, 25 May 2013 16:48:42 +0000
Subject: [PATCH] =?UTF-8?q?Report=20de=20r20519=20:=20Ferme=20#2804=20:=20?=
 =?UTF-8?q?les=20post=20AJAX=20sur=20un=20site=20iso-truc=20sont=20pr?=
 =?UTF-8?q?=C3=A9sum=C3=A9s=20en=20utf=20et=20import=C3=A9s=20dans=20le=20?=
 =?UTF-8?q?charset=20local=20par=20=5Frequest().=20Mais=20ce=20n'est=20pas?=
 =?UTF-8?q?=20forc=C3=A9ment=20le=20cas=20et=20le=20test=20de=20la=20preg?=
 =?UTF-8?q?=20n'est=20pas=20fiable,=20ce=20qui=20supprime=20des=20accents?=
 =?UTF-8?q?=20bien=20encod=C3=A9s=20a=20tort.=20On=20compl=C3=A8te=20le=20?=
 =?UTF-8?q?test=20par=20un=20is=5Futf8()=20plus=20fiable=20ce=20qui=20r?=
 =?UTF-8?q?=C3=A9soud=20mon=20cas=20test=20sur=20edition=20d'un=20document?=
 =?UTF-8?q?,=20titre=20:=20"titre=20av=C3=A9=20un=20accent"=20A=20noter=20?=
 =?UTF-8?q?que=20le=20bug=20n'=C3=A9tait=20pas=20syst=C3=A9matique=20sur?=
 =?UTF-8?q?=20un=20m=C3=AAme=20site=20(certains=20post=20passant=20sans=20?=
 =?UTF-8?q?probl=C3=A8me,=20d'autres=20non).=20Cela=20peut=20venir=20du=20?=
 =?UTF-8?q?type=20de=20formulaire=20qui=20est=20post=C3=A9=20parfois=20par?=
 =?UTF-8?q?=20une=20iframe=20en=20cas=20d'upload.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ecrire/inc/utils.php | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php
index 9e1c3a2909..f93568e29c 100644
--- a/ecrire/inc/utils.php
+++ b/ecrire/inc/utils.php
@@ -313,8 +313,12 @@ function _request($var, $c=false) {
 	AND isset($GLOBALS['meta']['charset'])
 	AND $GLOBALS['meta']['charset'] != 'utf-8'
 	AND is_string($a)
-	AND preg_match(',[\x80-\xFF],', $a)) {
-		include_spip('inc/charsets');
+	// check rapide mais pas fiable
+	AND preg_match(',[\x80-\xFF],', $a)
+	// check fiable
+	AND include_spip('inc/charsets')
+	AND is_utf8($a)
+	) {
 		return importer_charset($a, 'utf-8');
 	}
 
-- 
GitLab