diff options
author | mrjive <mrjive@mrjive.it> | 2018-01-30 16:13:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-30 16:13:30 +0100 |
commit | 7ac4b477020689572a50dbc777c968263e86f6c4 (patch) | |
tree | 470336bcbdf0f989d48fb2c3349bd0ac0513da42 /include/bbcode.php | |
parent | c2abbe2c238fa4d66e8a088c7d271acaa7e20876 (diff) | |
parent | d24cf0b85b24cb8d6d10e9fe66fed568f9fb08b2 (diff) | |
download | volse-hubzilla-7ac4b477020689572a50dbc777c968263e86f6c4.tar.gz volse-hubzilla-7ac4b477020689572a50dbc777c968263e86f6c4.tar.bz2 volse-hubzilla-7ac4b477020689572a50dbc777c968263e86f6c4.zip |
Merge pull request #13 from redmatrix/dev
Dev
Diffstat (limited to 'include/bbcode.php')
-rw-r--r-- | include/bbcode.php | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/include/bbcode.php b/include/bbcode.php index de32bd57a..0c85a0a4e 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -108,7 +108,11 @@ function tryzrlvideo($match) { if($zrl) $link = zid($link); - return '<video controls="controls" preload="none" src="' . str_replace(' ','%20',$link) . '" style="width:100%; max-width:' . App::$videowidth . 'px"><a href="' . str_replace(' ','%20',$link) . '">' . $link . '</a></video>'; + $static_link = get_config('system','video_default_poster','images/video_poster.jpg'); + if($static_link) + $poster = 'poster="' . escape_tags($static_link) . '" ' ; + + return '<video ' . $poster . ' controls="controls" preload="none" src="' . str_replace(' ','%20',$link) . '" style="width:100%; max-width:' . App::$videowidth . 'px"><a href="' . str_replace(' ','%20',$link) . '">' . $link . '</a></video>'; } // [noparse][i]italic[/i][/noparse] turns into @@ -610,11 +614,23 @@ function bb_observer($Text) { return $Text; } +function bb_code_protect($s) { + return 'b64.^9e%.' . base64_encode($s) . '.b64.$9e%'; +} + +function bb_code_unprotect($s) { + return preg_replace_callback('|b64\.\^9e\%\.(.*?)\.b64\.\$9e\%|ism','bb_code_unprotect_sub',$s); +} + +function bb_code_unprotect_sub($match) { + return base64_decode($match[1]); +} + function bb_code($match) { if(strpos($match[0], "<br />")) - return '<code>' . trim($match[1]) . '</code>'; + return '<code>' . bb_code_protect(trim($match[1])) . '</code>'; else - return '<code class="inline-code">' . trim($match[1]) . '</code>'; + return '<code class="inline-code">' . bb_code_protect(trim($match[1])) . '</code>'; } function bb_code_options($match) { @@ -628,11 +644,11 @@ function bb_code_options($match) { } else { $style = ""; } - return '<code class="'. $class .'" style="'. $style .'">' . trim($match[2]) . '</code>'; + return '<code class="'. $class .'" style="'. $style .'">' . bb_code_protect(trim($match[2])) . '</code>'; } function bb_highlight($match) { - return text_highlight($match[2],strtolower($match[1])); + return bb_code_protect(text_highlight($match[2],strtolower($match[1]))); } function bb_fixtable_lf($match) { @@ -822,6 +838,17 @@ function bbcode($Text, $options = []) { $Text = str_replace(array("\t", " "), array(" ", " "), $Text); + + // Check for [code] text + if (strpos($Text,'[code]') !== false) { + $Text = preg_replace_callback("/\[code\](.*?)\[\/code\]/ism", 'bb_code', $Text); + } + + // Check for [code options] text + if (strpos($Text,'[code ') !== false) { + $Text = preg_replace_callback("/\[code(.*?)\](.*?)\[\/code\]/ism", 'bb_code_options', $Text); + } + // Set up the parameters for a URL search string $URLSearchString = "^\[\]"; // Set up the parameters for a MAIL search string @@ -1062,16 +1089,6 @@ function bbcode($Text, $options = []) { $Text = preg_replace("/\[font=(.*?)\](.*?)\[\/font\]/sm", "<span style=\"font-family: $1;\">$2</span>", $Text); } - // Check for [code] text - if (strpos($Text,'[code]') !== false) { - $Text = preg_replace_callback("/\[code\](.*?)\[\/code\]/ism", 'bb_code', $Text); - } - - // Check for [code options] text - if (strpos($Text,'[code ') !== false) { - $Text = preg_replace_callback("/\[code(.*?)\](.*?)\[\/code\]/ism", 'bb_code_options', $Text); - } - if(strpos($Text,'[/summary]') !== false) { $Text = preg_replace_callback("/^(.*?)\[summary\](.*?)\[\/summary\](.*?)$/ism", 'bb_summary', $Text); @@ -1288,6 +1305,7 @@ function bbcode($Text, $options = []) { // replace escaped links in code= blocks $Text = str_replace('%eY9-!','http', $Text); + $Text = bb_code_unprotect($Text); $Text = preg_replace('/\[\&\;([#a-z0-9]+)\;\]/', '&$1;', $Text); |