[SPIP] v3.2.1-->v3.2.2
[lhc/web/www.git] / www / ecrire / inc / texte_mini.php
index cacd557..27c2109 100644 (file)
@@ -3,7 +3,7 @@
 /***************************************************************************\
  *  SPIP, Systeme de publication pour l'internet                           *
  *                                                                         *
- *  Copyright (c) 2001-2017                                                *
+ *  Copyright (c) 2001-2019                                                *
  *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
  *                                                                         *
  *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
@@ -319,7 +319,7 @@ function echappe_retour_modeles($letexte, $interdire_scripts = false) {
  * @return string
  *     Texte coupé
  **/
-function couper($texte, $taille = 50, $suite = ' (...)') {
+function couper($texte, $taille = 50, $suite = null) {
        if (!($length = strlen($texte)) or $taille <= 0) {
                return '';
        }
@@ -369,6 +369,9 @@ function couper($texte, $taille = 50, $suite = '&nbsp;(...)') {
        $long = spip_substr($texte, 0, max($taille - 4, 1));
        $u = $GLOBALS['meta']['pcre_u'];
        $court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
+       if (is_null($suite)) {
+               $suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
+       }
        $points = $suite;
 
        // trop court ? ne pas faire de (...)
@@ -453,10 +456,24 @@ function echapper_faux_tags($letexte) {
  * @return string
  */
 function echapper_html_suspect($texte, $strict=true) {
-       if (!$texte
-               or strpos($texte, '<') === false or strpos($texte, '=') === false) {
+       static $echapper_html_suspect;
+       if (!$texte or !is_string($texte)) {
+               return $texte;
+       }
+
+       if (!isset($echapper_html_suspect)) {
+               $echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true);
+       }
+       // si fonction personalisee, on delegue
+       if ($echapper_html_suspect) {
+               return $echapper_html_suspect($texte, $strict);
+       }
+
+       if (strpos($texte, '<') === false
+         or strpos($texte, '=') === false) {
                return $texte;
        }
+
        // quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
        // car sinon on declenche sur les modeles ou ressources
        if (!$strict and
@@ -473,7 +490,7 @@ function echapper_html_suspect($texte, $strict=true) {
                if (!function_exists('attribut_html')) {
                        include_spip('inc/filtres');
                }
-               $texte = "<mark title='".attribut_html(_T('erreur_contenu_suspect'))."'>⚠️</mark> ".$texte;
+               $texte = "<mark class='danger-js' title='".attribut_html(_T('erreur_contenu_suspect'))."'>⚠️</mark> ".$texte;
        }
 
        return $texte;