Skip to content

Commit

Permalink
Ensure redent is idempotent (doesn't add 8 spaces to already dedented…
Browse files Browse the repository at this point in the history
… values).
  • Loading branch information
jaraco committed Sep 11, 2024
1 parent 20295ec commit db14d96
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions importlib_metadata/_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ def __getitem__(self, item):
def _repair_headers(self):
def redent(value):
"Correct for RFC822 indentation"
if not value or '\n' not in value:
indent = ' ' * 8
if not value or '\n' + indent not in value:
return value
return textwrap.dedent(' ' * 8 + value)
return textwrap.dedent(indent + value)

headers = [(key, redent(value)) for key, value in vars(self)['_headers']]
if self._payload:
Expand Down

0 comments on commit db14d96

Please sign in to comment.