From 944800c9c9d3885f2bd7a91f110bbbb92f33a11d Mon Sep 17 00:00:00 2001
From: Fil <fil@rezo.net>
Date: Sun, 15 Jan 2006 14:08:03 +0000
Subject: [PATCH] =?UTF-8?q?bug=20avec=20safehtml()=20:=20une=20fois=20plan?=
 =?UTF-8?q?t=C3=A9=20par=20un=20"<style>"=20non=20ferm=C3=A9,=20il=20effac?=
 =?UTF-8?q?e=20tout.=20Il=20faut=20le=20reset()=20plus=20fortement=20(?=
 =?UTF-8?q?=C3=A0=20programmer=20en=20mode=20OO=20=3F)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ecrire/inc_texte.php3 | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/ecrire/inc_texte.php3 b/ecrire/inc_texte.php3
index c8e5db35ab..e7f271a810 100644
--- a/ecrire/inc_texte.php3
+++ b/ecrire/inc_texte.php3
@@ -330,6 +330,10 @@ function interdire_scripts($source) {
 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_once('XML_HTMLSAX3', _DIR_RESTREINT."safehtml/classes/");
 		if (@file_exists(XML_HTMLSAX3.'safehtml.php')) {
@@ -343,7 +347,15 @@ function safehtml($t) {
 	}
 
 	if ($test > 0) {
-		$process->clear(); # vider le buffer _xhtml de safehtml
+		# reset ($process->clear() ne vide que _xhtml...),
+		# on doit pouvoir programmer ca plus propremement
+		$process->$_xhtml = '';
+		$process->$_counter = array();
+		$process->$_stack = array();
+		$process->$_dcCounter = array();
+		$process->$_dcStack = array();
+		$process->$_listScope = 0; 
+		$process->$_liStack = array();
 		$t = $process->parse($t);
 	}
 
-- 
GitLab