/***************************************************************************\
* 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. *
* @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 '';
}
$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 : ' (...)');
+ }
$points = $suite;
// trop court ? ne pas faire de (...)
* @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
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;