Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fixed #18916 -- Allowed non-ASCII headers. #339

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants
Owner

aaugustin commented Sep 7, 2012

No description provided.

@claudep claudep commented on an outdated diff Sep 7, 2012

django/http/__init__.py
- e.reason += ', HTTP response headers must be in US-ASCII format'
+ # Convert bytestring using given charset
+ value = value.decode(charset)
+ else:
+ if isinstance(value, str):
+ # Ensure string is valid in given charset
+ value.decode(charset)
+ else:
+ # Convert unicode string to given charset
+ value = value.encode(charset)
+ except UnicodeError as e:
+ if mime_encode:
+ # The extra str() is required because .encode() returns unicode
+ # under Python 2. This behavior is triggered by the 'utf-8'
+ # charset registration in django.core.mail.message.
+ value = str(Header(value, 'utf-8').encode())
@claudep

claudep Sep 7, 2012

Member

or fix #12422 ?

@aaugustin aaugustin closed this Sep 7, 2012

nanuxbe pushed a commit to nanuxbe/django that referenced this pull request Jul 2, 2016

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