From 3a50a0b71572d0f5cc5c5aed1df8592c3e9e4dce Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 3 May 2024 10:23:36 +0200 Subject: deal with li tags earlier seems to be more straight forward also add test for li without closing tag --- include/html2bbcode.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'include/html2bbcode.php') 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( - "
  • ", - "

  • "), - array( - "
  • ", - "
  • "), - $message); // remove namespaces $message = preg_replace('=<(\w+):(.+?)>=', '', $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(['
  • ', '

  • '], '[*]', $message); + $message = str_replace(['

  • ', ''], '', $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]"); -- cgit v1.2.3