Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
gh-143346: Fix calculation of the line width for wrapped Base64 in plistlib#143347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -509,6 +509,69 @@ def test_bytes(self): | ||
| data2 = plistlib.dumps(pl2) | ||
| self.assertEqual(data, data2) | ||
| def test_bytes_indent(self): | ||
| header = ( | ||
| b'<?xml version="1.0" encoding="UTF-8"?>\n' | ||
| b'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n' | ||
| b'<plist version="1.0">\n') | ||
| data = [{'bytes': bytes(range(50))}] | ||
| pl = plistlib.dumps(data) | ||
| self.assertEqual(pl, header + | ||
| b'<array>\n' | ||
| b'\t<dict>\n' | ||
| b'\t\t<key>bytes</key>\n' | ||
| b'\t\t<data>\n' | ||
| b'\t\tAAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKiss\n' | ||
| b'\t\tLS4vMDE=\n' | ||
| b'\t\t</data>\n' | ||
| b'\t</dict>\n' | ||
| b'</array>\n' | ||
| b'</plist>\n') | ||
| def dumps_with_indent(data, indent): | ||
| fp = BytesIO() | ||
| writer = plistlib._PlistWriter(fp, indent=indent) | ||
| writer.write(data) | ||
| return fp.getvalue() | ||
| pl = dumps_with_indent(data, b' ') | ||
| self.assertEqual(pl, header + | ||
| b'<array>\n' | ||
| b' <dict>\n' | ||
| b' <key>bytes</key>\n' | ||
| b' <data>\n' | ||
| b' AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDE=\n' | ||
| b' </data>\n' | ||
| b' </dict>\n' | ||
| b'</array>\n' | ||
| b'</plist>\n') | ||
| pl = dumps_with_indent(data, b' \t') | ||
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This catches the original bug. | ||
| self.assertEqual(pl, header + | ||
| b'<array>\n' | ||
| b' \t<dict>\n' | ||
| b' \t \t<key>bytes</key>\n' | ||
| b' \t \t<data>\n' | ||
| b' \t \tAAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKiss\n' | ||
| b' \t \tLS4vMDE=\n' | ||
| b' \t \t</data>\n' | ||
| b' \t</dict>\n' | ||
| b'</array>\n' | ||
| b'</plist>\n') | ||
| pl = dumps_with_indent(data, b'\t ') | ||
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This catches a bug in my initial fix in #143216. | ||
| self.assertEqual(pl, header + | ||
| b'<array>\n' | ||
| b'\t <dict>\n' | ||
| b'\t \t <key>bytes</key>\n' | ||
| b'\t \t <data>\n' | ||
| b'\t \t AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygp\n' | ||
| b'\t \t KissLS4vMDE=\n' | ||
| b'\t \t </data>\n' | ||
| b'\t </dict>\n' | ||
| b'</array>\n' | ||
| b'</plist>\n') | ||
| def test_loads_str_with_xml_fmt(self): | ||
| pl = self._create() | ||
| b = plistlib.dumps(pl) | ||
| @@ -581,7 +644,6 @@ def test_appleformatting(self): | ||
| self.assertEqual(data, TESTDATA[fmt], | ||
| "generated data was not identical to Apple's output") | ||
| def test_appleformattingfromliteral(self): | ||
| self.maxDiff = None | ||
| for fmt in ALL_FORMATS: | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Fix incorrect wrapping of the Base64 data in :class:`!plistlib._PlistWriter` | ||
| when the indent contains a mix of tabs and spaces. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests non-default indentation.