# HG changeset patch # User Franz Glasner # Date 1735847751 -3600 # Node ID 8b73dca5db97297aa2b1b3e7edf695f37e5b866d # Parent 3a18d71d7c503339f89351151a89434d2f277686 Encode the link targets as netstrings also before digesting them diff -r 3a18d71d7c50 -r 8b73dca5db97 cutils/treesum.py --- a/cutils/treesum.py Thu Jan 02 20:52:49 2025 +0100 +++ b/cutils/treesum.py Thu Jan 02 20:55:51 2025 +0100 @@ -165,7 +165,7 @@ if not handle_root_logical and os.path.islink(root): linktgt = util.fsencode(os.readlink(root)) linkdgst = algorithm[0]() - linkdgst.update(linktgt) + linkdgst.update(b"%d:%s," % (len(linktgt), linktgt)) dir_dgst = algorithm[0]() dir_dgst.update(b"1:S,3:./@,") dir_dgst.update(linkdgst.digest()) @@ -185,7 +185,7 @@ if dn.is_symlink and not follow_directory_symlinks: linktgt = util.fsencode(os.readlink(dn.path)) linkdgst = algorithm[0]() - linkdgst.update(linktgt) + linkdgst.update(b"%d:%s," % (len(linktgt), linktgt)) dir_dgst.update(b"1:S,%d:%s," % (len(dn.fsname), dn.fsname)) dir_dgst.update(linkdgst.digest()) opath = "/".join(top) + "/" + dn.name if top else dn.name