const DIASPORA = 3;
const CONNECTORS = 4;
const TWITTER_API = 5;
+ const NPF = 6;
const OSTATUS = 7;
const TWITTER = 8;
const BACKLINK = 8;
/*
* The previously spacefied [noparse][ i ]italic[ /i ][/noparse],
- * now turns back and the [noparse] tags are trimed
+ * now turns back and the [noparse] tags are trimmed
* returning [i]italic[/i]
*
* @param array $match
/// @todo Have a closer look at the different html modes
// Handle attached links or videos
- if (in_array($simple_html, [self::MASTODON_API, self::TWITTER_API, self::ACTIVITYPUB])) {
+ if ($simple_html == self::NPF) {
+ $text = self::removeAttachment($text);
+ } elseif (in_array($simple_html, [self::MASTODON_API, self::TWITTER_API, self::ACTIVITYPUB])) {
$text = self::replaceAttachment($text);
} elseif (!in_array($simple_html, [self::INTERNAL, self::EXTERNAL, self::CONNECTORS])) {
$text = self::replaceAttachment($text, true);
});
}
- // leave open the posibility of [map=something]
+ // leave open the possibility of [map=something]
// this is replaced in Item::prepareBody() which has knowledge of the item location
if (strpos($text, '[/map]') !== false) {
$text = preg_replace_callback(
"/\[[iz]mg\=(.*?)\](.*?)\[\/[iz]mg\]/ism",
function ($matches) use ($simple_html, $uriid) {
$matches[1] = self::proxyUrl($matches[1], $simple_html, $uriid);
- $matches[2] = htmlspecialchars($matches[2], ENT_COMPAT);
- return '<img src="' . $matches[1] . '" alt="' . $matches[2] . '" title="' . $matches[2] . '">';
+ $alt = htmlspecialchars($matches[2], ENT_COMPAT);
+ // Fix for Markdown problems with Diaspora, see issue #12701
+ if (($simple_html != self::DIASPORA) || strpos($matches[2], '"') === false) {
+ return '<img src="' . $matches[1] . '" alt="' . $alt . '" title="' . $alt . '">';
+ } else {
+ return '<img src="' . $matches[1] . '" alt="' . $alt . '">';
+ }
},
$text
);
// Simplify "video" element
$text = preg_replace('(\[video[^\]]*?\ssrc\s?=\s?([^\s\]]+)[^\]]*?\].*?\[/video\])ism', '[video]$1[/video]', $text);
- if ($try_oembed) {
+ if ($simple_html == self::NPF) {
+ $text = preg_replace(
+ "/\[video\](.*?)\[\/video\]/ism",
+ '</p><video src="$1" controls width="100%" height="auto">$1</video><p>',
+ $text
+ );
+ $text = preg_replace(
+ "/\[audio\](.*?)\[\/audio\]/ism",
+ '</p><audio src="$1" controls>$1">$1</audio><p>',
+ $text
+ );
+ } elseif ($try_oembed) {
// html5 video and audio
$text = preg_replace(
"/\[video\](.*?\.(ogg|ogv|oga|ogm|webm|mp4).*?)\[\/video\]/ism",