aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/html2bbcode.php9
-rw-r--r--tests/unit/includes/BBCodeTest.php8
2 files changed, 11 insertions, 6 deletions
diff --git a/include/html2bbcode.php b/include/html2bbcode.php
index e95e498c9..e1c0572f5 100644
--- a/include/html2bbcode.php
+++ b/include/html2bbcode.php
@@ -126,6 +126,9 @@ function html2bbcode($message)
//$message = mb_convert_encoding($message, 'HTML-ENTITIES', "UTF-8");
$message = mb_encode_numericentity($message, [0x80, 0x10FFFF, 0, ~0], 'UTF-8');
+ $message = preg_replace('/\<ul(.*?)\>/', '[list]', $message);
+ $message = preg_replace('/\<ol(.*?)\>/', '[list=1]', $message);
+ $message = str_replace(['</ul>', '</ol>'], '[/list]', $message);
$message = str_replace(['<li><p>', '<li>'], '[*]', $message);
$message = str_replace(['</p></li>', '</li>'], '', $message);
@@ -147,9 +150,6 @@ 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]');
@@ -206,9 +206,6 @@ function html2bbcode($message)
node2bbcode($doc, 'audio', array('src'=>'/(.+)/'), '[audio]$1', '[/audio]');
// node2bbcode($doc, 'iframe', array('src'=>'/(.+)/'), '[iframe]$1', '[/iframe]');
- node2bbcode($doc, 'ul', array(), "[list]", "[/list]");
- node2bbcode($doc, 'ol', array(), "[list=1]", "[/list]");
-
node2bbcode($doc, 'hr', array(), "[hr]", "");
// node2bbcode($doc, 'table', array(), "", "");
diff --git a/tests/unit/includes/BBCodeTest.php b/tests/unit/includes/BBCodeTest.php
index 2697c5069..34e127a30 100644
--- a/tests/unit/includes/BBCodeTest.php
+++ b/tests/unit/includes/BBCodeTest.php
@@ -239,6 +239,10 @@ class BBCodeTest extends UnitTestCase {
'<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]'
],
+ 'double 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><li>list 1</li><li>list 2</li><li>list 3</li></ul></ul></ul>',
+ '[list][*]list 1[*]list 2[*]list 3[list][*]list 1[*]list 2[*]list 3[list][*]list 1[*]list 2[*]list 3[/list][/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]'
@@ -246,6 +250,10 @@ class BBCodeTest extends UnitTestCase {
'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]'
+ ],
+ 'double 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><li>list 1<li>list 2<li>list 3</ul></ul></ul>',
+ '[list][*]list 1[*]list 2[*]list 3[list][*]list 1[*]list 2[*]list 3[list][*]list 1[*]list 2[*]list 3[/list][/list][/list]'
]
];
}