Skip to content

Commit

Permalink
Fallback to url if text is disabled (#15830)
Browse files Browse the repository at this point in the history
* Fallback to url if text is disabled

Fix `htmlspecialchars(): Argument #1 ($string) must be of type string, null given`

* Update models/Document/Editable/Link.php

Readable code

Co-authored-by: Divesh Pahuja <divesh.pahuja@pimcore.com>

---------

Co-authored-by: Divesh Pahuja <divesh.pahuja@pimcore.com>
  • Loading branch information
fracsi and dvesh3 committed Sep 14, 2023
1 parent fd33da4 commit 2a08a8d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion models/Document/Editable/Link.php
Expand Up @@ -171,7 +171,12 @@ public function frontend()

$attribs = array_unique($attribs);

return '<a href="'.$url.'" '.implode(' ', $attribs).'>' . $prefix . ($noText ? '' : htmlspecialchars($disabledText ? $url : $this->data['text'])) . $suffix . '</a>';
$text = '';
if (!$noText) {
$text = htmlspecialchars($disabledText ? $url : ($this->data['text'] ?? $url));
}

return '<a href="'.$url.'" '.implode(' ', $attribs).'>' . $prefix . $text . $suffix . '</a>';
}

return '';
Expand Down

0 comments on commit 2a08a8d

Please sign in to comment.