python / python/cpython

plistlib inherits expat's newline-normalizing behavior, which can corrupt data in XML plists

Open
#139,423 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

This is just a special case of #84561 but it came up in the specific circumstance of XML plists in MOPUp, here: https://github.com/glyph/MOPUp/pull/448/files#r2280646662

I also discovered that it is possible to get the unmodified data, by changing plistlib._PlistParser.handle_data to look like this:

    def handle_data(self, data):
        ctx = self.parser.GetInputContext()
        if data == '\n' and ctx[0:1] != b'\n':
            data = ctx[0:1].decode("utf-8")
        self.data.append(data)

so we are not totally bound by the whims of Expat here; these types of bug could be fixed.

CPython versions tested on:

3.12, 3.13, 3.11

Operating systems tested on:

macOS

Linked PRs
  • gh-148305

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with plistlib._PlistParser.handle_data and the input-context behavior described in the report. Verify how XML plist data is currently normalized and ensure unmodified data is preserved; check linked PR gh-148305 before starting because this work may already be underway.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.