From 9c47cc23c340352a49c9be529a5ce692557eb910 Mon Sep 17 00:00:00 2001 From: Ibrahim BinAlshikh Date: Wed, 10 Jun 2026 15:16:58 +0300 Subject: [PATCH 01/12] test: add failing tests for issues #55, #56, #57, #58, #59, #60, #62, #63, #71, #74, #75, #76, #77 Add tests that verify the existence of bugs reported in the listed issues. Tests for #57, #74, and #75 already pass as those bugs were fixed alongside the test additions. --- WebFiori/Ui/HTMLNode.php | 39 ++++++- tests/WebFiori/Tests/Ui/HTMLNodeTest.php | 127 ++++++++++++++++++++++ tests/WebFiori/Tests/Ui/HTMLTableTest.php | 9 ++ 3 files changed, 169 insertions(+), 6 deletions(-) diff --git a/WebFiori/Ui/HTMLNode.php b/WebFiori/Ui/HTMLNode.php index fffecc8..fa50e47 100644 --- a/WebFiori/Ui/HTMLNode.php +++ b/WebFiori/Ui/HTMLNode.php @@ -843,7 +843,7 @@ public static function fixBareLineFeed(string $str) : string { if ($char == "\n") { if ($index != 0 && $str[$index - 1] != "\r") { //Bare line feed found. Replace with \r\n - $finalStr = trim($finalStr).HTMLDoc::NL; + $finalStr = rtrim($finalStr, "\n").HTMLDoc::NL; } else { $finalStr .= $char; } @@ -1160,11 +1160,29 @@ public function getStyle() : array { if ($styleStr !== null) { $retVal = []; - $arr1 = explode(';', trim($styleStr,';')); + $styleStr = trim($styleStr, ';'); + $depth = 0; + $current = ''; - foreach ($arr1 as $val) { - $exp = explode(':', $val); - $retVal[$exp[0]] = $exp[1]; + for ($i = 0; $i < strlen($styleStr); $i++) { + $ch = $styleStr[$i]; + + if ($ch === '(') { + $depth++; + } else if ($ch === ')') { + $depth--; + } + + if ($ch === ';' && $depth === 0) { + $this->parseStylePair($current, $retVal); + $current = ''; + } else { + $current .= $ch; + } + } + + if (trim($current) !== '') { + $this->parseStylePair($current, $retVal); } return $retVal; @@ -1651,7 +1669,7 @@ public function open() : string { $valType = gettype($val); $quoted = $this->isQuotedAttribute(); - if (!$quoted && $valType == "integer" || $valType == 'double') { + if (!$quoted && ($valType == "integer" || $valType == 'double')) { $retVal .= ' '.$attr.'='.$val; } else { if ($val != '' && !$quoted && strpos($val, '?') === false @@ -2817,6 +2835,15 @@ private function setParentHelper(?HTMLNode $node) { *