Browse Source

feat: prise en charge de l'option collecter_liens=false sur la fonction modeles_collecter() et optimisation

remotes/checkIfPRContentChanged-1659714283585166050/refactor_texte_safety
Cerdic 2 months ago
parent
commit
cb8f350f01
  1. 12
      ecrire/inc/modeles.php

12
ecrire/inc/modeles.php

@ -64,11 +64,14 @@ function modeles_collecter($texte, bool $collecter_liens = true) {
$regs[] = '';
}
[, $mod, $type, $id, $params, $fin] = $regs;
[, $mod, $type, $id, $params, $fermeture_lien] = $regs;
if (
$fin
and preg_match('/<a\s[^<>]*>\s*$/i', substr($texte, 0, $a), $r)
$collecter_liens
and $fermeture_lien
and $before = substr($texte, $pos, $a - $pos)
and stripos($before, '<a') !== false
and preg_match('/<a\s[^<>]*>\s*$/i', $before, $r)
) {
$lien = [
'href' => extraire_attribut($r[0], 'href'),
@ -81,6 +84,9 @@ function modeles_collecter($texte, bool $collecter_liens = true) {
$a -= $n;
$longueur = $n+strlen($regs[0]);
} else {
if ($fermeture_lien) {
$mod = rtrim(substr($mod, 0, -strlen($fermeture_lien)));
}
$lien = false;
$longueur = strlen($mod);
}

Loading…
Cancel
Save