From bd75b68a7c6c9235033e418bcfe2d0df2dd34e6c Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 16 Jul 2014 17:39:40 -0700 Subject: shield share meta info from markdown processing. --- include/bb2diaspora.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 41001d216..f15a34e99 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -67,6 +67,17 @@ function bb_tag_preg_replace($pattern, $replace, $name, $s) { return $string; } +function share_shield($m) { + return str_replace($m[1],'!=+=+=!' . base64url_encode($m[1]) . '=+!=+!=',$m[0]); +} + +function share_unshield($m) { + $x = str_replace(array('!=+=+=!','=+!=+!='),array('',''),$m[1]); + return str_replace($m[1], base64url_decode($x), $m[0]); +} + + + // we don't want to support a bbcode specific markdown interpreter // and the markdown library we have is pretty good, but provides HTML output. // So we'll use that to convert to HTML, then convert the HTML back to bbcode, @@ -93,6 +104,8 @@ function diaspora2bb($s,$use_zrl = false) { // This seems to work $s = preg_replace('/\#([^\s\#])/','#$1',$s); + $s = preg_replace_callback('/\[share(.*?)\]/ism','share_shield',$s); + $s = Markdown($s); $s = str_replace('#','#',$s); @@ -123,6 +136,10 @@ function diaspora2bb($s,$use_zrl = false) { // remove duplicate adjacent code tags $s = preg_replace("/(\[code\])+(.*?)(\[\/code\])+/ism","[code]$2[/code]", $s); + + $s = preg_replace_callback('/\[share(.*?)\]/ism','share_unshield',$s); + + // Don't show link to full picture (until it is fixed) $s = scale_external_images($s, false); -- cgit v1.2.3