quotes in image alt text - again

This commit is contained in:
Mike Macgirvin 2024-07-29 16:33:35 +10:00
parent fcf28a99e9
commit b0dfef6f49

View file

@ -4790,14 +4790,14 @@ class Activity
}
// Friendica attachment weirdness
// Check both the attachment image and href since they can be different and the one in the href is a different link with different resolution.
// Otheriwse you'll get duplicated images
// Otherwise, you'll get duplicated images
if (isset($a['image'])) {
if (self::media_not_in_body($a['image'], $item['body']) && self::media_not_in_body($a['href'], $item['body'])) {
if (isset($a['name']) && $a['name']) {
$alt = htmlspecialchars($a['name'], ENT_QUOTES, 'UTF-8', false);
// Escape brackets by converting to unicode full-width bracket since regular brackets will confuse multicode/bbcode parsing.
// The full width bracket isn't quite as alien looking as most other unicode bracket replacements.
$alt = str_replace(['[', ']'], ['[', ']'], $alt);
$alt = str_replace(['[', ']', '"'], ['[', ']', '\"'], $alt);
$item['body'] .= "\n\n" . '[img alt="' . $alt . '"]' . $a['href'] . '[/img]';
} else {
$item['body'] .= "\n\n" . '[img]' . $a['href'] . '[/img]';