Skip to content

Decode extended MIME parameters when reading PO catalogs - #1536

Open
echo666939 wants to merge 1 commit into
python-babel:masterfrom
echo666939:fix/po-extended-header-parameters-1533
Open

echo666939 wants to merge 1 commit into
python-babel:masterfrom
echo666939:fix/po-extended-header-parameters-1533

Conversation

@echo666939

Copy link
Copy Markdown

Fixes #1533.

The email parser returns a tuple for extended MIME parameters. Decode those values with email.utils.collapse_rfc2231_value at the header parsing boundary so charset and plural-form handling both receive strings. Ordinary parameter values keep their existing parsing behavior.

The regression reads a byte-stream PO catalog with an ISO-8859-1 translation and extended plural parameters. It failed with AttributeError before the change and passes afterward. On Windows with Python 3.11, all 129 tests in test_pofile.py and test_catalog.py passed. The full tests/messages run had 527 passes and one failure in the setuptools command smoke test (init_catalog is not registered in this uninstalled checkout).

OpenAI Codex assisted with the code, regression test, validation, and PR text.

Decode RFC 2231 values returned by the email parser before consuming the catalog charset and plural forms. Leave ordinary string parameters untouched.

Fixes python-babel#1533

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

read_po crashes on RFC 2231 extended parameters (charset*=, nplurals*=) in PO headers

1 participant