branchmap-v3: detect invalid headerline and raise error
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 27 Sep 2024 02:27:54 +0200
changeset 51972 dd3ccda3abc8
parent 51971 69bfd6b242ed
child 51973 bb281ecf4036
branchmap-v3: detect invalid headerline and raise error Otherwise, broken cache file would be accept as valid, but empty.
mercurial/branchmap.py
--- 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 = {}