aboutsummaryrefslogtreecommitdiffstats
path: root/include/bbcode.php
diff options
context:
space:
mode:
authorredmatrix <mike@macgirvin.com>2016-10-06 15:59:27 -0700
committerredmatrix <mike@macgirvin.com>2016-10-06 15:59:27 -0700
commit48f70e55aa67339d4b5505b1e717ccc6d5651834 (patch)
treeff336b5dba32bfbdd0b4bce64cf4a228c19ce65e /include/bbcode.php
parent3250d7532092608651649d27619f7b245d426d03 (diff)
downloadvolse-hubzilla-48f70e55aa67339d4b5505b1e717ccc6d5651834.tar.gz
volse-hubzilla-48f70e55aa67339d4b5505b1e717ccc6d5651834.tar.bz2
volse-hubzilla-48f70e55aa67339d4b5505b1e717ccc6d5651834.zip
try naked embed before submission instead of at render time
Diffstat (limited to 'include/bbcode.php')
-rw-r--r--include/bbcode.php16
1 files changed, 15 insertions, 1 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index 6a58475d0..a82b658b1 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -12,7 +12,6 @@ require_once('include/hubloc.php');
function tryoembed($match) {
$url = ((count($match) == 2) ? $match[1] : $match[2]);
-
$o = oembed_fetch_url($url);
if ($o['type'] == 'error')
@@ -22,6 +21,18 @@ function tryoembed($match) {
return $html;
}
+
+function nakedoembed($match) {
+ $url = ((count($match) == 2) ? $match[1] : $match[2]);
+
+ $o = oembed_fetch_url($url);
+
+ if ($o['type'] == 'error')
+ return $match[0];
+
+ return '[embed]' . $url . '[/embed]';
+}
+
function tryzrlaudio($match) {
$link = $match[1];
$zrl = is_matrix_url($link);
@@ -645,6 +656,9 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false)
$urlchars = '[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,\@]';
if (strpos($Text,'http') !== false) {
+ if($tryoembed) {
+ $Text = preg_replace_callback("/([^\]\='".'"'."\/]|^|\#\^)(https?\:\/\/$urlchars+)/ism", 'tryoembed', $Text);
+ }
$Text = preg_replace("/([^\]\='".'"'."\/]|^|\#\^)(https?\:\/\/$urlchars+)/ism", '$1<a href="$2" target="_blank" >$2</a>', $Text);
}