From b1eed641ef54892ab838ef858b2d73f1afb54ec1 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Tue, 27 Jul 2021 22:42:59 +0200 Subject: [PATCH] Remove duplicate HTML escaping on foreign keys modal Only twig needs this data and will escape it Also fixed the test as it could not run by itself because of missing version constants for setTheme Signed-off-by: William Desportes --- libraries/classes/BrowseForeigners.php | 21 +++++++-------------- test/classes/BrowseForeignersTest.php | 5 +++-- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/libraries/classes/BrowseForeigners.php b/libraries/classes/BrowseForeigners.php index c865588d30..302ca3d495 100644 --- a/libraries/classes/BrowseForeigners.php +++ b/libraries/classes/BrowseForeigners.php @@ -277,22 +277,15 @@ class BrowseForeigners private function getDescriptionAndTitle(string $description): array { if (mb_strlen($description) <= $this->limitChars) { - $description = htmlspecialchars( - $description - ); $descriptionTitle = ''; } else { - $descriptionTitle = htmlspecialchars( - $description - ); - $description = htmlspecialchars( - mb_substr( - $description, - 0, - $this->limitChars - ) - . '...' - ); + $descriptionTitle = $description; + $description = mb_substr( + $description, + 0, + $this->limitChars + ) + . '...'; } return [ diff --git a/test/classes/BrowseForeignersTest.php b/test/classes/BrowseForeignersTest.php index aeaf090385..7381d073da 100644 --- a/test/classes/BrowseForeignersTest.php +++ b/test/classes/BrowseForeignersTest.php @@ -18,6 +18,7 @@ class BrowseForeignersTest extends AbstractTestCase protected function setUp(): void { parent::setUp(); + parent::defineVersionConstants(); parent::setTheme(); $GLOBALS['cfg']['LimitChars'] = 50; $GLOBALS['cfg']['MaxRows'] = 25; @@ -135,7 +136,7 @@ class BrowseForeignersTest extends AbstractTestCase $this->assertEquals( [ - 'foobar<baz', + 'foobarcallFunction( @@ -152,7 +153,7 @@ class BrowseForeignersTest extends AbstractTestCase $this->assertEquals( [ 'fooba...', - 'foobar<baz', + 'foobarcallFunction( $browseForeigners,