Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(8)

Side by Side Diff: Lib/plistlib.py

Issue 26707: plistlib fails to parse bplist with 0x80 UID values
Patch Set: Created 3 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 r"""plistlib.py -- a tool to generate and parse MacOSX .plist files. 1 r"""plistlib.py -- a tool to generate and parse MacOSX .plist files.
2 2
3 The property list (.plist) file format is a simple XML pickle supporting 3 The property list (.plist) file format is a simple XML pickle supporting
4 basic object types, like dictionaries, lists, numbers and strings. 4 basic object types, like dictionaries, lists, numbers and strings.
5 Usually the top level object is a dictionary. 5 Usually the top level object is a dictionary.
6 6
7 To write out a plist file, use the dump(value, file) 7 To write out a plist file, use the dump(value, file)
8 function. 'value' is the top level object, 'file' is 8 function. 'value' is the top level object, 'file' is
9 a (writable) file object. 9 a (writable) file object.
10 10
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 696
697 elif tokenH == 0x50: # ascii string 697 elif tokenH == 0x50: # ascii string
698 s = self._get_size(tokenL) 698 s = self._get_size(tokenL)
699 result = self._fp.read(s).decode('ascii') 699 result = self._fp.read(s).decode('ascii')
700 return result 700 return result
701 701
702 elif tokenH == 0x60: # unicode string 702 elif tokenH == 0x60: # unicode string
703 s = self._get_size(tokenL) 703 s = self._get_size(tokenL)
704 return self._fp.read(s * 2).decode('utf-16be') 704 return self._fp.read(s * 2).decode('utf-16be')
705 705
706 # tokenH == 0x80 is documented as 'UID' and appears to be used for 706 elif tokenH == 0x80:
707 # keyed-archiving, not in plists. 707 s = self._get_size(tokenL)
708 return self._fp.read(s).decode('ascii')
708 709
709 elif tokenH == 0xA0: # array 710 elif tokenH == 0xA0: # array
710 s = self._get_size(tokenL) 711 s = self._get_size(tokenL)
711 obj_refs = self._read_refs(s) 712 obj_refs = self._read_refs(s)
712 return [self._read_object(self._object_offsets[x]) 713 return [self._read_object(self._object_offsets[x])
713 for x in obj_refs] 714 for x in obj_refs]
714 715
715 # tokenH == 0xB0 is documented as 'ordset', but is not actually 716 # tokenH == 0xB0 is documented as 'ordset', but is not actually
716 # implemented in the Apple reference code. 717 # implemented in the Apple reference code.
717 718
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 writer = _FORMATS[fmt]["writer"](fp, sort_keys=sort_keys, skipkeys=skipkeys) 1017 writer = _FORMATS[fmt]["writer"](fp, sort_keys=sort_keys, skipkeys=skipkeys)
1017 writer.write(value) 1018 writer.write(value)
1018 1019
1019 1020
1020 def dumps(value, *, fmt=FMT_XML, skipkeys=False, sort_keys=True): 1021 def dumps(value, *, fmt=FMT_XML, skipkeys=False, sort_keys=True):
1021 """Return a bytes object with the contents for a .plist file. 1022 """Return a bytes object with the contents for a .plist file.
1022 """ 1023 """
1023 fp = BytesIO() 1024 fp = BytesIO()
1024 dump(value, fp, fmt=fmt, skipkeys=skipkeys, sort_keys=sort_keys) 1025 dump(value, fp, fmt=fmt, skipkeys=skipkeys, sort_keys=sort_keys)
1025 return fp.getvalue() 1026 return fp.getvalue()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+