##// END OF EJS Templates
changelog: handle decoding of NULs in extra more carefully (issue3156)...
Matt Mackall -
r15661:20ae902c stable
parent child Browse files
Show More
@@ -24,9 +24,20 b' def _string_escape(text):'
24 return text.replace('\0', '\\0')
24 return text.replace('\0', '\\0')
25
25
26 def decodeextra(text):
26 def decodeextra(text):
27 """
28 >>> decodeextra(encodeextra({'foo': 'bar', 'baz': chr(0) + '2'}))
29 {'foo': 'bar', 'baz': '\\x002'}
30 >>> decodeextra(encodeextra({'foo': 'bar', 'baz': chr(92) + chr(0) + '2'}))
31 {'foo': 'bar', 'baz': '\\\\\\x002'}
32 """
27 extra = {}
33 extra = {}
28 for l in text.split('\0'):
34 for l in text.split('\0'):
29 if l:
35 if l:
36 if '\\0' in l:
37 # fix up \0 without getting into trouble with \\0
38 l = l.replace('\\\\', '\\\\\n')
39 l = l.replace('\\0', '\0')
40 l = l.replace('\n', '')
30 k, v = l.decode('string_escape').split(':', 1)
41 k, v = l.decode('string_escape').split(':', 1)
31 extra[k] = v
42 extra[k] = v
32 return extra
43 return extra
General Comments 0
You need to be logged in to leave comments. Login now