Show More
@@ -57,7 +57,12 b' def _parse(data):' | |||||
57 | raise ValueError(b'Manifest lines not in sorted order.') |
|
57 | raise ValueError(b'Manifest lines not in sorted order.') | |
58 | prev = l |
|
58 | prev = l | |
59 | f, n = l.split(b'\0') |
|
59 | f, n = l.split(b'\0') | |
60 |
|
|
60 | nl = len(n) | |
|
61 | if 64 < nl: | |||
|
62 | # modern hash, full width | |||
|
63 | yield f, bin(n[:64]), n[64:] | |||
|
64 | elif 40 < nl < 45: | |||
|
65 | # legacy hash, always sha1 | |||
61 | yield f, bin(n[:40]), n[40:] |
|
66 | yield f, bin(n[:40]), n[40:] | |
62 | else: |
|
67 | else: | |
63 | yield f, bin(n), b'' |
|
68 | yield f, bin(n), b'' | |
@@ -265,9 +270,15 b' class _lazymanifest(object):' | |||||
265 | if pos == -1: |
|
270 | if pos == -1: | |
266 | return (data[1], data[2]) |
|
271 | return (data[1], data[2]) | |
267 | zeropos = data.find(b'\x00', pos) |
|
272 | zeropos = data.find(b'\x00', pos) | |
|
273 | nlpos = data.find(b'\n', zeropos) | |||
268 | assert 0 <= needle <= len(self.positions) |
|
274 | assert 0 <= needle <= len(self.positions) | |
269 | assert len(self.extrainfo) == len(self.positions) |
|
275 | assert len(self.extrainfo) == len(self.positions) | |
270 | hashval = unhexlify(data, self.extrainfo[needle], zeropos + 1, 40) |
|
276 | hlen = nlpos - zeropos - 1 | |
|
277 | # Hashes sometimes have an extra byte tucked on the end, so | |||
|
278 | # detect that. | |||
|
279 | if hlen % 2: | |||
|
280 | hlen -= 1 | |||
|
281 | hashval = unhexlify(data, self.extrainfo[needle], zeropos + 1, hlen) | |||
271 | flags = self._getflags(data, needle, zeropos) |
|
282 | flags = self._getflags(data, needle, zeropos) | |
272 | return (hashval, flags) |
|
283 | return (hashval, flags) | |
273 |
|
284 |
General Comments 0
You need to be logged in to leave comments.
Login now