|
@@ -404,6 +404,8 @@ class Archive:
|
|
|
class RobustUnpacker():
|
|
|
"""A restartable/robust version of the streaming msgpack unpacker
|
|
|
"""
|
|
|
+ item_keys = [msgpack.packb(name) for name in ('path', 'mode', 'source', 'chunks', 'rdev', 'xattrs', 'user', 'group', 'uid', 'gid', 'mtime')]
|
|
|
+
|
|
|
def __init__(self, validator):
|
|
|
super(RobustUnpacker, self).__init__()
|
|
|
self.validator = validator
|
|
@@ -430,10 +432,18 @@ class RobustUnpacker():
|
|
|
while self._resync:
|
|
|
if not data:
|
|
|
raise StopIteration
|
|
|
- # Abort early if the data does not look like a serialized item
|
|
|
- if len(data) < 2 or ((data[0] & 0xf0) != 0x80) or ((data[1] & 0xe0) != 0xa0) or not b'\xa4path' in data:
|
|
|
+ # Abort early if the data does not look like a serialized dict
|
|
|
+ if len(data) < 2 or ((data[0] & 0xf0) != 0x80) or ((data[1] & 0xe0) != 0xa0):
|
|
|
data = data[1:]
|
|
|
continue
|
|
|
+ # Make sure it looks like an item dict
|
|
|
+ for pattern in self.item_keys:
|
|
|
+ if data[1:].startswith(pattern):
|
|
|
+ break
|
|
|
+ else:
|
|
|
+ data = data[1:]
|
|
|
+ continue
|
|
|
+
|
|
|
self._unpacker = msgpack.Unpacker(object_hook=StableDict)
|
|
|
self._unpacker.feed(data)
|
|
|
try:
|