Do not create spurious links in item body

The 'str_replace' will match any HTML element that starts with '<a',
including things like '<address' or '<article', thus creating spurious
links in item bodies. Fix that by simply adding one whitespace.

Fixes issue #527.

Signed-off-by: David Engster <deng@randomsample.de>
This commit is contained in:
David Engster 2020-05-18 22:00:41 +02:00 committed by Benjamin Brahmer
parent 1345578a31
commit 864794461f
1 changed files with 1 additions and 1 deletions

View File

@ -291,7 +291,7 @@ class Item extends Entity implements IAPI, \JsonSerializable
{
// FIXME: this should not happen if the target="_blank" is already
// on the link
$body = str_replace('<a', '<a target="_blank" rel="noreferrer"', $body);
$body = str_replace('<a ', '<a target="_blank" rel="noreferrer" ', $body);
if ($this->body !== $body) {
$this->body = $body;