X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbb2diaspora.php;h=4a82635e57f065246adc702dc8d9d49b042ede47;hb=dafc84390db4b57e5958f1af386c778b481c7d04;hp=d509a2e31c3dd68b0827020b050595cbd7765a56;hpb=4ef33ac6ebbf7418742a9ee7a4a549808754eb1f;p=friendica.git
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index d509a2e31c..4a82635e57 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -109,23 +109,23 @@ function bb2diaspora($Text,$preserve_nl = false) {
// "
" into a deeper nested element until it crashes. So pre-format
// the lists as Diaspora lists before sending the $Text to bbcode()
//
- // Note that regular expressions are really not suitable for parsing
- // text with opening and closing tags, so nested lists may make things
- // wonky
- $endlessloop = 0;
- while ((strpos($Text, "[/list]") !== false) && (strpos($Text, "[list") !== false) &&
- (strpos($Text, "[/ul]") !== false) && (strpos($Text, "[ul]") !== false) &&
- (strpos($Text, "[/ol]") !== false) && (strpos($Text, "[ol]") !== false) && (++$endlessloop < 20)) {
+ // Note that to get nested lists to work for Diaspora, we would need
+ // to define the closing tag for the list elements. So nested lists
+ // are going to be flattened out in Diaspora for now
+/* $endlessloop = 0;
+ while ((((strpos($Text, "[/list]") !== false) && (strpos($Text, "[list") !== false)) ||
+ ((strpos($Text, "[/ol]") !== false) && (strpos($Text, "[ol]") !== false)) ||
+ ((strpos($Text, "[/ul]") !== false) && (strpos($Text, "[ul]") !== false))) && (++$endlessloop < 20)) {
$Text = preg_replace_callback("/\[list\](.*?)\[\/list\]/is", 'diaspora_ul', $Text);
- $Text = preg_replace_callback("/\[ul\](.*?)\[\/ul\]/is", 'diaspora_ul', $Text);
$Text = preg_replace_callback("/\[list=1\](.*?)\[\/list\]/is", 'diaspora_ol', $Text);
$Text = preg_replace_callback("/\[list=i\](.*?)\[\/list\]/s",'diaspora_ol', $Text);
$Text = preg_replace_callback("/\[list=I\](.*?)\[\/list\]/s", 'diaspora_ol', $Text);
$Text = preg_replace_callback("/\[list=a\](.*?)\[\/list\]/s", 'diaspora_ol', $Text);
$Text = preg_replace_callback("/\[list=A\](.*?)\[\/list\]/s", 'diaspora_ol', $Text);
+ $Text = preg_replace_callback("/\[ul\](.*?)\[\/ul\]/is", 'diaspora_ul', $Text);
$Text = preg_replace_callback("/\[ol\](.*?)\[\/ol\]/is", 'diaspora_ol', $Text);
}
-
+*/
// Convert it to HTML - don't try oembed
$Text = bbcode($Text, $preserve_nl, false);
@@ -133,6 +133,12 @@ function bb2diaspora($Text,$preserve_nl = false) {
$md = new Markdownify(false, false, false);
$Text = $md->parseString($Text);
+ // If the text going into bbcode() has a plain URL in it, i.e.
+ // with no [url] tags around it, it will come out of parseString()
+ // looking like: , which gets removed by strip_tags().
+ // So take off the angle brackets of any such URL
+ $Text = preg_replace("//is", "http$1", $Text);
+
// Remove all unconverted tags
$Text = strip_tags($Text);