X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbb2diaspora.php;h=ffe6b3b970bd5dbc4137ac8a98e280a6867e9540;hb=111495423c46df986f5baef45b4c9495c280cc26;hp=f007417903b2ed7a9367417fc998fc44f3b06665;hpb=f07658accf3baa162c9757e34dcab3b1c1abe3b6;p=friendica.git diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index f007417903..ffe6b3b970 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -155,6 +155,9 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) { // $Text = preg_replace("/\[url\=([^\[\]]*)\]\s*\[img\](.*?)\[\/img\]\s*\[\/url\]/ism", // "[url]$1[/url]\n[img]$2[/img]", $Text); + // Remove the avatar picture since that isn't looking good on the other side + //$Text = preg_replace("/\[share(.*?)avatar\s?=\s?'.*?'\s?(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","\n[share$1$2]$3[/share]",$Text); + // Convert it to HTML - don't try oembed $Text = bbcode($Text, $preserve_nl, false); @@ -162,6 +165,22 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) { $md = new Markdownify(false, false, false); $Text = $md->parseString($Text); + // The Markdownify converter converts underscores '_' in URLs to '\_', which + // messes up the URL. Manually fix these + $count = 1; + $pos = bb_find_open_close($Text, '[', ']', $count); + while($pos !== false) { + $start = substr($Text, 0, $pos['start']); + $subject = substr($Text, $pos['start'], $pos['end'] - $pos['start'] + 1); + $end = substr($Text, $pos['end'] + 1); + + $subject = str_replace('\_', '_', $subject); + $Text = $start . $subject . $end; + + $count++; + $pos = bb_find_open_close($Text, '[', ']', $count); + } + // 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().