diff options
author | Mario <mario@mariovavti.com> | 2021-03-10 11:09:49 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2021-03-15 08:50:53 +0000 |
commit | 6cfa2572a8cf9a014002262e383ecef55f1b6a57 (patch) | |
tree | 56e2c21036b9447671b57e1db26add2e61d0fe72 | |
parent | 04ec986bf77ac5e99d99a756376f933c395fb925 (diff) | |
download | volse-hubzilla-6cfa2572a8cf9a014002262e383ecef55f1b6a57.tar.gz volse-hubzilla-6cfa2572a8cf9a014002262e383ecef55f1b6a57.tar.bz2 volse-hubzilla-6cfa2572a8cf9a014002262e383ecef55f1b6a57.zip |
do not parse bbcode in summary - issue #1532
-rw-r--r-- | Zotlabs/Module/Item.php | 2 | ||||
-rw-r--r-- | include/bbcode.php | 27 |
2 files changed, 22 insertions, 7 deletions
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index f9a13a131..def3f76dd 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -831,12 +831,10 @@ class Item extends Controller { // and will require alternatives for alternative content-types (text/html, text/markdown, text/plain, etc.) // we may need virtual or template classes to implement the possible alternatives - $summary = cleanup_bbcode($summary); $body = cleanup_bbcode($body); // Look for tags and linkify them - $results = linkify_tags($summary, ($uid) ? $uid : $profile_uid); $results = linkify_tags($body, ($uid) ? $uid : $profile_uid); if($results) { diff --git a/include/bbcode.php b/include/bbcode.php index a5ef6760b..388a828c4 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -152,6 +152,18 @@ function bb_spacefy($st) { } // The previously spacefied [noparse][ i ]italic[ /i ][/noparse], +// now turns back returning [noparse][i]italic[/i][/noparse] +function bb_unspacefy($st) { + $whole_match = $st[0]; + $captured = $st[1]; + $spacefied = preg_replace("/\[ (.*?) \]/", "[$1]", $captured); + $new_str = str_replace($captured, $spacefied, $whole_match); + + return $new_str; +} + + +// The previously spacefied [noparse][ i ]italic[ /i ][/noparse], // now turns back and the [noparse] tags are trimmed // returning [i]italic[/i] @@ -1097,6 +1109,9 @@ function bbcode($Text, $options = []) { if (strpos($Text,'[pre]') !== false) { $Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_spacefy',$Text); } + if (strpos($Text,'[summary]') !== false) { + $Text = preg_replace_callback("/\[summary\](.*?)\[\/summary\]/ism", 'bb_spacefy',$Text); + } $Text = bb_format_attachdata($Text); @@ -1438,11 +1453,6 @@ function bbcode($Text, $options = []) { $Text = preg_replace("/\[font=(.*?)\](.*?)\[\/font\]/sm", "<span style=\"font-family: $1;\">$2</span>", $Text); } - - if(strpos($Text,'[/summary]') !== false) { - $Text = preg_replace_callback("/^(.*?)\[summary\](.*?)\[\/summary\](.*?)$/is", 'bb_summary', $Text); - } - // Check for [spoiler] text $endlessloop = 0; while ((strpos($Text, "[/spoiler]")!== false) and (strpos($Text, "[spoiler]") !== false) and (++$endlessloop < 20)) { @@ -1611,6 +1621,13 @@ function bbcode($Text, $options = []) { } + if (strpos($Text,'[summary]') !== false) { + $Text = preg_replace_callback("/\[summary\](.*?)\[\/summary\]/ism", 'bb_unspacefy',$Text); + } + if(strpos($Text,'[/summary]') !== false) { + $Text = preg_replace_callback("/^(.*?)\[summary\](.*?)\[\/summary\](.*?)$/is", 'bb_summary', $Text); + } + // Unhide all [noparse] contained bbtags unspacefying them // and triming the [noparse] tag. if (strpos($Text,'[noparse]') !== false) { |