Browse Source

Pour la correction typo des caps et les correction auto : il faut echapper toutes les balises html dangeureuses (ie balises non triviales) qui risque d'etre modifiees a tort (modif d'une url par exemple). En revanche, pas la peine d'echapper les raccourcis liens qui le sont deja en amont.

svn/root/tags/v1.5.2
cedric@yterium.com 10 years ago
parent
commit
3554f11ff6
  1. 28
      orthotypo_fonctions.php
  2. 2
      paquet.xml

28
orthotypo_fonctions.php

@ -111,6 +111,23 @@ function orthotypo_filtre_texte_echappe($texte, $filtre, $balises='', $args=NULL
return echappe_retour($texte, 'FILTRETEXTECHAPPE');
}
function orthotypo_echappe_balises_html($texte){
// prudence : on protege le contenu de toute balise html
if (strpos($texte, '<')!==false){
// tout
#$texte = preg_replace_callback(',<[^>]*>,UmsS', 'orthotypo_echappe_balise_html', $texte);
// dangereux uniquement
$texte = preg_replace_callback(',<\w+\b[^>]+>,UmsS', 'orthotypo_echappe_balise_html', $texte);
}
return $texte;
}
function orthotypo_echappe_balise_html($m) {
if (strpos($m[0],'class="base64')!==false) return $m[0];
var_dump($m[0]);
return code_echappement($m[0], 'FILTRETEXTECHAPPE',true,'span');
}
/* *********************************************************************************************************************
* Guillemets
@ -416,6 +433,7 @@ function orthotypo_caps_rempl($texte){
(?:[A-Z]+\.\s?)+) # Followed by the same thing at least once more
(?:\s|\b|$))/xS";
}
$texte = orthotypo_echappe_balises_html($texte);
return preg_replace_callback($cap_finder, 'orthotypo_caps_replace_callback', $texte);
}
@ -465,20 +483,14 @@ function orthotypo_corrections_rempl($texte) {
if (is_null($str)){
list($str,$preg) = orthotypo_corrections_regles();
}
// prudence : on protege les urls dans les raccourcis de liens SPIP
if (strpos($texte, '[')!==false)
$texte = preg_replace_callback(',(\[[^][]*->>?)([^]]*)(?=\]),msS', 'orthotypo_corrections_echappe_liens', $texte);
$texte = orthotypo_echappe_balises_html($texte);
if (count($str))
$texte = str_replace($str[0], $str[1], $texte);
if (count($preg))
$texte = preg_replace($preg[0], $preg[1], $texte);
return echappe_retour($texte, 'CORRECTIONS');
}
function orthotypo_corrections_echappe_liens($m) {
return $m[1].code_echappement($m[2], 'CORRECTIONS');
return $texte;
}
// Fonctions de traitement sur #TEXTE

2
paquet.xml

@ -1,7 +1,7 @@
<paquet
prefix="orthotypo"
categorie="edition"
version="1.2.1"
version="1.2.2"
etat="test"
compatibilite="[3.0.0;3.0.*]"
logo="prive/themes/spip/images/orthotypo-32.png"

Loading…
Cancel
Save