From 502044c4956951bc3092d6e77fd9a95d4f093de8 Mon Sep 17 00:00:00 2001
From: Ghislain Loas <ghislo@sandbox.pergame.net>
Date: Tue, 7 Jul 2015 15:54:38 +0200
Subject: [PATCH] hotline #23975 keep br in rating comments

---
 library/Class/AdminVar.php                     |  1 -
 library/ZendAfi/View/Helper/Avis.php           |  7 +------
 .../View/Helper/Accueil/CritiquesTest.php      | 18 ++++++++++++++++++
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php
index cd6b9b510c6..e25078334ef 100644
--- a/library/Class/AdminVar.php
+++ b/library/Class/AdminVar.php
@@ -716,7 +716,6 @@ class Class_AdminVar extends Storm_Model_Abstract {
 
 
 	public function validate() {
-		xdebug_break();
 		$this->getMeta()->validate($this);
 	}
 
diff --git a/library/ZendAfi/View/Helper/Avis.php b/library/ZendAfi/View/Helper/Avis.php
index 315ba30fbea..5a93253f3ed 100644
--- a/library/ZendAfi/View/Helper/Avis.php
+++ b/library/ZendAfi/View/Helper/Avis.php
@@ -284,7 +284,7 @@ class ZendAfi_View_Helper_Avis extends ZendAfi_View_Helper_BaseHelper {
 
 
 	protected function _formatTextAvis($avis) {
-		return $this->_formatWithTruncate($this->view->escape(strip_tags($avis->getAvis())));
+		return $this->_formatWithTruncate($this->view->escape(strip_tags(str_replace(['<br>', '<br/>', '<br />'], "\n", $avis->getAvis()))));
 	}
 
 
@@ -298,9 +298,4 @@ class ZendAfi_View_Helper_Avis extends ZendAfi_View_Helper_BaseHelper {
 		return ['text_avis' => nl2br($txt_avis) . ' [...]',
 						'lire_la_suite' => true];
 	}
-
-
-	protected function _is_html($value) {
-		return preg_match('/<[^<]+>/', $value);
-	}
 }
\ No newline at end of file
diff --git a/tests/library/ZendAfi/View/Helper/Accueil/CritiquesTest.php b/tests/library/ZendAfi/View/Helper/Accueil/CritiquesTest.php
index d36e4dedff7..a83ac6a2d7c 100644
--- a/tests/library/ZendAfi/View/Helper/Accueil/CritiquesTest.php
+++ b/tests/library/ZendAfi/View/Helper/Accueil/CritiquesTest.php
@@ -106,6 +106,16 @@ abstract class CritiquesAvisTestCase extends ViewHelperTestCase {
 																								 'statut' => 1,
 																								 'notices' => [$millenium]]);
 
+		$avis_millenium_from_suplo_with_html = $this->fixture('Class_AvisNotice',
+																													['id' => 2342,
+																													 'entete' => 'Excellent<br> !',
+																													 'avis' => '<div class="should not be present"><br>Tout au long de ce livre<br>, le suspense est intense.</div>',
+																													 'note' => 5,
+																													 'date_avis' => '2010-03-18 13:00:00',
+																													 'user' => $super_lolo,
+																													 'statut' => 1,
+																													 'notices' => [$millenium]]);
+
 		$avis_orphan = $this->fixture('Class_AvisNotice',
 																	['id' => 34,
 																	 'entete' => 'J\'ai oublié',
@@ -159,6 +169,14 @@ class CritiquesWithVignettesTest extends CritiquesAvisTestCase {
 	}
 
 
+	/** @test */
+	public function superLoloCommentWithHtmlShouldBeCutAfterToutAu() {
+				$this->assertXPathContentContains($this->html,
+																					'//p', '
+Tout au [...]');
+	}
+
+
 	/** @test */
 	public function loloCommentShouldBeCutAfterSuspenceIntence() {
 				$this->assertXPathContentContains($this->html,
-- 
GitLab