From b97a68343ec5c4ff1fae25ff5dc41f1a2ce6a17f Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 26 Nov 2021 04:29:10 +0100 Subject: =?UTF-8?q?disco=20modif/suppr=20d=C3=A9sordre?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/Security.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 controller/Security.php (limited to 'controller/Security.php') diff --git a/controller/Security.php b/controller/Security.php new file mode 100644 index 0000000..98d2e74 --- /dev/null +++ b/controller/Security.php @@ -0,0 +1,23 @@ +1, // protection contre les élements et attributs dangereux + 'elements'=>'h2, h3, h4, p, br, span, i, strong, u, mark, blockquote, li, ol, ul, a, figure, hr, img, figcaption, table, tbody, tr, td', // paramètre optionnel: les balises non indiquées sont supprimées + 'deny_attribute'=>'id', // gêner le JS hostile + // on garde 'class' et 'style' utilisés par le ckediteur + ); + private static $specHtmLawed = ''; // optionnel: faire qu'un certain élément puisse n'avoir que certains attributs + + public static function secureString($chaine) + { + $chaine = htmLawed($chaine, self::$configHtmLawed, self::$specHtmLawed); + $chaine = trim($chaine); // supprimer espaces, tabulations et sauts de ligne en début et fin de chaine (pour l'entrée de l'éditeur) + return $chaine; + } +} -- cgit v1.2.3