changeset 51972:dd3ccda3abc8

branchmap-v3: detect invalid headerline and raise error Otherwise, broken cache file would be accept as valid, but empty.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 27 Sep 2024 02:27:54 +0200
parents 69bfd6b242ed
children bb281ecf4036
files mercurial/branchmap.py
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/branchmap.py	Fri Sep 27 00:55:54 2024 +0200
+++ b/mercurial/branchmap.py	Fri Sep 27 02:27:54 2024 +0200
@@ -937,6 +937,10 @@
     def _load_header(cls, repo, lineiter):
         header_line = next(lineiter)
         pieces = header_line.rstrip(b'\n').split(b" ")
+        for p in pieces:
+            if b'=' not in p:
+                msg = b"invalid header_line: %r" % header_line
+                raise ValueError(msg)
         cache_keys = dict(p.split(b'=', 1) for p in pieces)
 
         args = {}