Parse XMP tag bytes without decoding to string by radarhere · Pull Request #8960 · python-pillow/Pillow
Resolves #8957
The issue has found that XMP tag bytes may contain non-ascii bytes. This raises an error when trying to parse them to get the orientation.
Lines 1541 to 1544 in 3c71559
| if not xmp_tags and (xmp_tags := self.info.get("xmp")): | |
| xmp_tags = xmp_tags.decode("utf-8") | |
| if xmp_tags: | |
| match = re.search(r'tiff:Orientation(="|>)([0-9])', xmp_tags) |
Instead of changing the XMP tag bytes to a string to match the pattern, this PR changes the pattern to bytes to match the XMP tag bytes.