From 73a9bd995056e9ba1f177f21417afda099d0c8e3 Mon Sep 17 00:00:00 2001
From: Cerdic <cedric@yterium.com>
Date: Fri, 24 Mar 2023 10:34:02 +0100
Subject: [PATCH] =?UTF-8?q?refactor:=20`extraire=5Fbalise()`=20s'appuie=20?=
 =?UTF-8?q?directement=20sur=20`extraire=5Fbalises()`=20plutot=20qu'avoir?=
 =?UTF-8?q?=20une=20double=20impl=C3=A9mentation?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ecrire/inc/filtres.php | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/ecrire/inc/filtres.php b/ecrire/inc/filtres.php
index 49daea8580..e73dcbe85c 100644
--- a/ecrire/inc/filtres.php
+++ b/ecrire/inc/filtres.php
@@ -2450,29 +2450,12 @@ function tags2dcsubject($tags) {
  *     - Tableau de résultats, si tableau en entrée.
  **/
 function extraire_balise($texte, $tag = 'a') {
+	$balises = extraire_balises($texte, $tag);
 	if (is_array($texte)) {
-		array_walk(
-			$texte,
-			function (&$a, $key, $t) {
-				$a = extraire_balise($a, $t);
-			},
-			$tag
-		);
-
-		return $texte;
+		return array_map(function(array $a) {return (empty($a) ? '' : reset($a));}, $balises);
 	}
 
-	if (
-		preg_match(
-			",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
-			$texte,
-			$regs
-		)
-	) {
-		return $regs[0];
-	}
-	
-	return '';
+	return (empty($balises) ? '' : reset($balises));
 }
 
 /**
-- 
GitLab