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 <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2021-07-27 22:42:59 +02:00
parent 436e0da185
commit b1eed641ef
No known key found for this signature in database
GPG Key ID: 90A0EF1B8251A889
2 changed files with 10 additions and 16 deletions

View File

@ -277,22 +277,15 @@ class BrowseForeigners
private function getDescriptionAndTitle(string $description): array private function getDescriptionAndTitle(string $description): array
{ {
if (mb_strlen($description) <= $this->limitChars) { if (mb_strlen($description) <= $this->limitChars) {
$description = htmlspecialchars(
$description
);
$descriptionTitle = ''; $descriptionTitle = '';
} else { } else {
$descriptionTitle = htmlspecialchars( $descriptionTitle = $description;
$description $description = mb_substr(
);
$description = htmlspecialchars(
mb_substr(
$description, $description,
0, 0,
$this->limitChars $this->limitChars
) )
. '...' . '...';
);
} }
return [ return [

View File

@ -18,6 +18,7 @@ class BrowseForeignersTest extends AbstractTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp(); parent::setUp();
parent::defineVersionConstants();
parent::setTheme(); parent::setTheme();
$GLOBALS['cfg']['LimitChars'] = 50; $GLOBALS['cfg']['LimitChars'] = 50;
$GLOBALS['cfg']['MaxRows'] = 25; $GLOBALS['cfg']['MaxRows'] = 25;
@ -135,7 +136,7 @@ class BrowseForeignersTest extends AbstractTestCase
$this->assertEquals( $this->assertEquals(
[ [
'foobar&lt;baz', 'foobar<baz',
'', '',
], ],
$this->callFunction( $this->callFunction(
@ -152,7 +153,7 @@ class BrowseForeignersTest extends AbstractTestCase
$this->assertEquals( $this->assertEquals(
[ [
'fooba...', 'fooba...',
'foobar&lt;baz', 'foobar<baz',
], ],
$this->callFunction( $this->callFunction(
$browseForeigners, $browseForeigners,