aboutsummaryrefslogtreecommitdiffstats
path: root/include/bbcode.php
diff options
context:
space:
mode:
authorfriendica <redmatrix@redmatrix.me>2015-04-06 21:26:40 -0700
committerfriendica <redmatrix@redmatrix.me>2015-04-06 21:26:40 -0700
commit3c05af6553ae1bef3a59c5f58aa7551021e34363 (patch)
tree0f108f165d777ba604ce06ed9fbeaeaf88d7ee1b /include/bbcode.php
parent3a3563a4b1673cdd86fdba01985ccfea98ab8b0e (diff)
downloadvolse-hubzilla-3c05af6553ae1bef3a59c5f58aa7551021e34363.tar.gz
volse-hubzilla-3c05af6553ae1bef3a59c5f58aa7551021e34363.tar.bz2
volse-hubzilla-3c05af6553ae1bef3a59c5f58aa7551021e34363.zip
make open tag work correctly for multiple invocations in the same text
Diffstat (limited to 'include/bbcode.php')
-rw-r--r--include/bbcode.php10
1 files changed, 7 insertions, 3 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index e97a96f87..5ee3d5d5e 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -291,6 +291,12 @@ function bb_map_location($match) {
return str_replace($match[0],'<div class="map" >' . generate_named_map($match[1]) . '</div>', $match[0]);
}
+function bbopentag($match) {
+ $rnd = mt_rand();
+ return "<br /><div onclick=\"openClose('opendiv-" . $rnd . "');return false;\" class=\"fakelink\">" . $match[1] . "</div><div id=\"opendiv-" . $rnd . "\" style=\"display: none;\">" . $match[2] . "</div>";
+}
+
+
function bb_sanitize_style($input) {
//whitelist property limits (0 = no limitation)
@@ -672,9 +678,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$endlessloop = 0;
while ((strpos($Text, "[/open]")!== false) and (strpos($Text, "[open=") !== false) and (++$endlessloop < 20)) {
$rnd = mt_rand();
- $Text = preg_replace("/\[open=(.*?)\](.*?)\[\/open\]/ism",
- "<br /><div onclick=\"openClose('opendiv-" . $rnd . "');return false;\" class=\"fakelink\">$1</div><div id=\"opendiv-" . $rnd . "\" style=\"display: none;\">$2</div>",
- $Text);
+ $Text = preg_replace_callback("/\[open=(.*?)\](.*?)\[\/open\]/ism",'bbopentag',$Text);
}