Skip to content

gh-143927: Normalize all line endings (CR, CRLF, and LF) in configparser#143929

Open
sethmlarson wants to merge 1 commit intopython:mainfrom
sethmlarson:normalize-newlines-configparser
Open

gh-143927: Normalize all line endings (CR, CRLF, and LF) in configparser#143929
sethmlarson wants to merge 1 commit intopython:mainfrom
sethmlarson:normalize-newlines-configparser

Conversation

@sethmlarson
Copy link
Copy Markdown
Contributor

@sethmlarson sethmlarson commented Jan 16, 2026

Comment thread Lib/configparser.py
value)
if value is not None or not self._allow_no_value:
value = delimiter + str(value).replace('\n', '\n\t')
# Convert all possible line-endings into '\n\t'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure the exact underlying security issue. As is, I think this will break round tripping on Windows; Text I/O used by the open expects to encode/decode newlines in particular formats on Windows by default (https://github.com/sethmlarson/cpython/blob/2a122fd420f5b425fd39848a48f5eb196cee2aa7/Lib/configparser.py#L753). See #143428 (comment) for a recent related case + more background links.

In the open calls can we use newline="" potentially?

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes stale Stale PR or inactive for long period of time. type-security A security issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants