shield share meta info from markdown processing.
This commit is contained in:
		| @@ -67,6 +67,17 @@ function bb_tag_preg_replace($pattern, $replace, $name, $s) { | |||||||
| 	return $string; | 	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 | // we don't want to support a bbcode specific markdown interpreter | ||||||
| // and the markdown library we have is pretty good, but provides HTML output. | // 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, | // 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 | 	// This seems to work | ||||||
| 	$s = preg_replace('/\#([^\s\#])/','#$1',$s); | 	$s = preg_replace('/\#([^\s\#])/','#$1',$s); | ||||||
|  |  | ||||||
|  | 	$s = preg_replace_callback('/\[share(.*?)\]/ism','share_shield',$s); | ||||||
|  |  | ||||||
| 	$s = Markdown($s); | 	$s = Markdown($s); | ||||||
|  |  | ||||||
| 	$s = str_replace('#','#',$s); | 	$s = str_replace('#','#',$s); | ||||||
| @@ -123,6 +136,10 @@ function diaspora2bb($s,$use_zrl = false) { | |||||||
| 	// remove duplicate adjacent code tags | 	// remove duplicate adjacent code tags | ||||||
| 	$s = preg_replace("/(\[code\])+(.*?)(\[\/code\])+/ism","[code]$2[/code]", $s); | 	$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) | 	// Don't show link to full picture (until it is fixed) | ||||||
| 	$s = scale_external_images($s, false); | 	$s = scale_external_images($s, false); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user