aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/html2bbcode.php18
-rw-r--r--tests/unit/includes/BBCodeTest.php8
2 files changed, 17 insertions, 9 deletions
diff --git a/include/html2bbcode.php b/include/html2bbcode.php
index b7f3ea4e3..e95e498c9 100644
--- a/include/html2bbcode.php
+++ b/include/html2bbcode.php
@@ -26,8 +26,12 @@ function node2bbcodesub(&$doc, $oldnode, $attributes, $startbb, $endbb)
$xpath = new DomXPath($doc);
$list = $xpath->query("//".$oldnode);
+
foreach ($list as $oldNode) {
+ if ($oldnode == 'li')
+ hz_syslog(print_r($oldNode,true));
+
$attr = array();
if ($oldNode->attributes->length)
foreach ($oldNode->attributes as $attribute)
@@ -113,13 +117,6 @@ function html2bbcode($message)
$message = str_replace("\r", "", $message);
- $message = str_replace(array(
- "<li><p>",
- "</p></li>"),
- array(
- "<li>",
- "</li>"),
- $message);
// remove namespaces
$message = preg_replace('=<(\w+):(.+?)>=', '<removeme>', $message);
@@ -129,7 +126,8 @@ function html2bbcode($message)
//$message = mb_convert_encoding($message, 'HTML-ENTITIES', "UTF-8");
$message = mb_encode_numericentity($message, [0x80, 0x10FFFF, 0, ~0], 'UTF-8');
-
+ $message = str_replace(['<li><p>', '<li>'], '[*]', $message);
+ $message = str_replace(['</p></li>', '</li>'], '', $message);
if(!$message)
return;
@@ -149,6 +147,9 @@ function html2bbcode($message)
node2bbcode($doc, 'html', array(), "", "");
node2bbcode($doc, 'body', array(), "", "");
+ node2bbcode($doc, 'li', array(), "[*]", "");
+
+
// Outlook-Quote - Variant 1
node2bbcode($doc, 'p', array('class'=>'MsoNormal', 'style'=>'margin-left:35.4pt'), '[quote]', '[/quote]');
@@ -205,7 +206,6 @@ function html2bbcode($message)
node2bbcode($doc, 'audio', array('src'=>'/(.+)/'), '[audio]$1', '[/audio]');
// node2bbcode($doc, 'iframe', array('src'=>'/(.+)/'), '[iframe]$1', '[/iframe]');
- node2bbcode($doc, 'li', array(), "[*]", "");
node2bbcode($doc, 'ul', array(), "[list]", "[/list]");
node2bbcode($doc, 'ol', array(), "[list=1]", "[/list]");
diff --git a/tests/unit/includes/BBCodeTest.php b/tests/unit/includes/BBCodeTest.php
index e1fba9fbc..2697c5069 100644
--- a/tests/unit/includes/BBCodeTest.php
+++ b/tests/unit/includes/BBCodeTest.php
@@ -238,6 +238,14 @@ class BBCodeTest extends UnitTestCase {
'nested list' => [
'<ul><li>list 1</li><li>list 2</li><li>list 3</li><ul><li>list 1</li><li>list 2</li><li>list 3</li></ul></ul>',
'[list][*]list 1[*]list 2[*]list 3[list][*]list 1[*]list 2[*]list 3[/list][/list]'
+ ],
+ 'list without closing li' => [
+ '<ul><li>list 1<li>list 2<li>list 3</ul>',
+ '[list][*]list 1[*]list 2[*]list 3[/list]'
+ ],
+ 'nested list without closing li' => [
+ '<ul><li>list 1<li>list 2<li>list 3<ul><li>list 1<li>list 2<li>list 3</ul></ul>',
+ '[list][*]list 1[*]list 2[*]list 3[list][*]list 1[*]list 2[*]list 3[/list][/list]'
]
];
}