From 87b7dfed5d53cc39198c11b9007a3b0bc7519516 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Tue, 17 Oct 2023 17:51:28 +0200 Subject: [PATCH] xml_node: skip whitespace in differs_from The 'Xml_node::differs_from' method takes the constructor arguments (addr, size) for a byte-wise comparison whereas 'with_raw_node' restricts the byte range to the actual XML tags. In cases where the XML start tag is preceeded by whitespace, both ranges can differ. Since the 'differs_from' method is meant for comparing actual XML nodes - not any whitespace around them - whitespace should be ignored on both operands. Issue #5029 --- repos/base/include/util/xml_node.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/repos/base/include/util/xml_node.h b/repos/base/include/util/xml_node.h index 69fbd3c8b8..e279c855d0 100644 --- a/repos/base/include/util/xml_node.h +++ b/repos/base/include/util/xml_node.h @@ -1041,10 +1041,14 @@ class Genode::Xml_node /** * Return true if this node differs from 'another' */ - bool differs_from(Xml_node const &another) const + bool differs_from(Xml_node const &other) const { - return size() != another.size() || - memcmp(_addr, another._addr, size()) != 0; + bool result = false; + other.with_raw_node([&] (char const * const other_start, size_t other_len) { + with_raw_node([&] (char const * const start, size_t len) { + result = (len != other_len) + || (memcmp(start, other_start, len) != 0); }); }); + return result; } };