From 67de3bce35de8158cd25750901a322cc02071c95 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 24 Nov 2023 23:33:59 -0800 Subject: Make xact hashes independent of posting order Also, support matching provided hashes against a prefixed of the generated hash. --- src/textual.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/textual.cc') diff --git a/src/textual.cc b/src/textual.cc index 9ad62602..af208232 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -2027,10 +2027,12 @@ xact_t * instance_t::parse_xact(char * line, previous_xact->get_tag("Hash")->to_string() : ""); if (xact->has_tag("Hash")) { string current_hash = xact->get_tag("Hash")->to_string(); - if (expected_hash != current_hash) { + if (! std::equal(expected_hash.begin(), + expected_hash.begin() + + std::min(expected_hash.size(), current_hash.size()), + current_hash.begin())) throw_(parse_error, _f("Expected hash %1% != %2%") % expected_hash % current_hash); - } } else { xact->set_tag("Hash", string_value(expected_hash)); } -- cgit v1.2.3