From b827824fafbbd71c3bd27f59ddaab1722c9db124 Mon Sep 17 00:00:00 2001
From: Michael Vogel
Date: Tue, 24 Feb 2015 20:39:02 +0100
Subject: [PATCH] Trying to avoid parser problems.
---
include/bb2diaspora.php | 23 +++++------------------
1 file changed, 5 insertions(+), 18 deletions(-)
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index e818acb83e..5a38852936 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -17,23 +17,11 @@ function diaspora2bb($s) {
$s = html_entity_decode($s,ENT_COMPAT,'UTF-8');
- // Simply remove cr.
+ // Remove CR to avoid problems with following code
//$s = str_replace("\r","",$s);
-/*
- // The parser has problems with unbalanced HTML elements
- $doc = new DOMDocument();
- $doc->preserveWhiteSpace = false;
- $s = mb_convert_encoding($s, 'HTML-ENTITIES', "UTF-8");
- $doctype = '';
- $encoding = '';
- @$doc->loadHTML($encoding.$doctype."".$s."");
- $doc->encoding = 'UTF-8';
- $s = $doc->saveHTML();
- $s = str_replace(array("", "", $doctype, $encoding), array("", "", "", ""), $s);
-*/
- // The parser has problems with unbalanced html elements
- $s = str_replace(array("
", "
", "", '
'),array("
", "
", "
", "
"),$s);
+ // The parser cannot handle paragraphs correctly
+ $s = str_replace(array("
", "", '
'),array("
", "
", "
"),$s);
// Escaping the hash tags
$s = preg_replace('/\#([^\s\#])/','#$1',$s);
@@ -116,9 +104,8 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) {
$a->save_timestamp($stamp1, "parser");
- // Libertree has a problem with escaped hashtags - Diaspora doesn't seem to.
- if (!$fordiaspora)
- $Text = str_replace(array('\#'), array('#'), $Text);
+ // Libertree has a problem with escaped hashtags.
+ $Text = str_replace(array('\#'), array('#'), $Text);
// Remove any leading or trailing whitespace, as this will mess up
// the Diaspora signature verification and cause the item to disappear