[SPIP] +2.1.12
[velocampus/web/www.git] / www / extensions / safehtml / inc / safehtml.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2009 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
8 * *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
12
13
14 if (!defined("_ECRIRE_INC_VERSION")) return;
15
16 // Controle la presence de la lib safehtml et cree la fonction
17 // de transformation du texte qui l'exploite
18 // http://doc.spip.org/@inc_safehtml_dist
19 function inc_safehtml_dist($t) {
20 static $process, $test;
21
22 if (!$test) {
23 $process = false;
24 if ($f = find_in_path('lib/safehtml/classes')) {
25 define('XML_HTMLSAX3', $f.'/');
26 require_once XML_HTMLSAX3.'safehtml.php';
27 $process = new safehtml();
28 $process->deleteTags[] = 'param'; // sinon bug Firefox
29 }
30 if ($process)
31 $test = 1; # ok
32 else
33 $test = -1; # se rabattre sur une fonction de securite basique
34 }
35
36 if ($test > 0) {
37 # reset ($process->clear() ne vide que _xhtml...),
38 # on doit pouvoir programmer ca plus propremement
39 $process->_counter = array();
40 $process->_stack = array();
41 $process->_dcCounter = array();
42 $process->_dcStack = array();
43 $process->_listScope = 0;
44 $process->_liStack = array();
45 # $process->parse(''); # cas particulier ?
46 $process->clear();
47 $t = $process->parse($t);
48 }
49 else
50 $t = entites_html($t); // tres laid, en cas d'erreur
51
52 return $t;
53 }
54
55 ?>