Skip to content

Remove unnecessary functionality from escapeOrCleanHtml #4320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions module/VuFind/src/VuFind/View/Helper/Root/EscapeOrCleanHtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,20 @@ public function __construct(protected Escaper $escaper, protected CleanHtml $cle
/**
* Invoke this helper: escape a value
*
* @param ?string $value Value to escape
* @param ?string $dataContext Data context (for fields that allow sanitized HTML)
* @param ?bool $allowHtml Whether to allow sanitized HTML if passed a PropertyString
* @param string $renderingContext Rendering context for cleaning HTML
* @param string|PropertyStringInterface $value Value to escape
* @param ?string $dataContext Data context (for fields that allow sanitized HTML)
* @param ?bool $allowHtml Whether to allow sanitized HTML if passed a
* PropertyString
* @param string $renderingContext Rendering context for cleaning HTML
*
* @return mixed Given a string, returns an escaped string, otherwise returns self
* @return mixed Returns an escaped or HTML-safe string
*/
public function __invoke(
$value = null,
string|PropertyStringInterface $value,
?string $dataContext = null,
?bool $allowHtml = null,
string $renderingContext = 'default'
) {
if (null === $value) {
return $this;
}
if ($value instanceof PropertyStringInterface) {
if (
($allowHtml ?? ($dataContext && ($this->htmlContexts[$dataContext] ?? false)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,4 @@ public function testEscapeOrCleanHtml(
$result = $escapeOrCleanHtml($input, $dataContext, $allowHtml, $renderingContext);
$this->assertEquals($expected, $result);
}

/**
* Test invoking without parameters
*
* @return void
*/
public function testInvokeWithoutParameters(): void
{
$escaper = new Escaper(false);
$cleanHtml = $this->createCleanHtmlHelper();
$escapeOrCleanHtml = new EscapeOrCleanHtml($escaper, $cleanHtml, []);
$this->assertEquals($escapeOrCleanHtml, $escapeOrCleanHtml());
}
}