This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: plistlib doesn't handle poorly-formatted plists
Type: behavior Stage: needs patch
Components: Library (Lib) Versions: Python 3.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Clay Caviness, ned.deily, ronaldoussoren
Priority: normal Keywords:

Created on 2020-04-24 19:52 by Clay Caviness, last changed 2022-04-11 14:59 by admin.

File name Uploaded Description Edit
Info.plist Clay Caviness, 2020-04-24 19:52
Messages (3)
msg367217 - (view) Author: Clay Caviness (Clay Caviness) * Date: 2020-04-24 19:52
Some Info.plist files are poorly formatted. I am using plistlib to read Info.plist file from various .app bundles. On some, plistlib.load raises a ValueError when trying to parse.

Examining one of these Info.plist files, it turns out *it* is poorly formatted, but while python's plistlib is unhappy, it passes "plutil -lint" just fine and "Foundation.NSDictionary.dictionaryWithContentsOfFile_" is happy to read it.

Here's a minimal sample plist file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
  <key>An array</key>
    <string>a string</string>
<key>A wild key appears!</key>
<string>it has a string</string>
    <string>another string</string>

plistlib (correctly, I think) says that's no good. Apple's tooling just ... changes the key to another string in the array and carries on.

I've attached an actual problematic Info.plist as well.
msg367218 - (view) Author: Clay Caviness (Clay Caviness) * Date: 2020-04-24 20:02
I expect the answer here to be "plistlib is correct, that's a poorly formatted plist", but since plistlib is "for reading and writing the “property list” files used mainly by Mac OS X and supports both binary and XML plist files", and Apple's own tooling handles these poorly-formatted files without error it was worth raising the issue.
msg367447 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2020-04-27 19:20
IMHO this is a bug and plistlib should behave the same as Apple’s libraries here.
Date User Action Args
2022-04-11 14:59:29adminsetgithub: 84561
2020-04-28 10:48:16ronaldoussorensettype: behavior
stage: needs patch
2020-04-27 19:20:20ronaldoussorensetmessages: + msg367447
2020-04-24 21:16:09serhiy.storchakasetnosy: + ronaldoussoren, ned.deily
2020-04-24 20:02:37Clay Cavinesssetmessages: + msg367218
2020-04-24 19:52:32Clay Cavinesscreate