Skip to content

fix: set charset for text/plain responses #9120

New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jennifer-richards
Copy link
Member

@jennifer-richards jennifer-richards commented Jul 10, 2025

The first commit fixes an observed bug with the iesg agenda_package.txt view, along with similar iesg views, by setting charset for the content type.

The second commit adjusts every place where we return an HTTP response with content_type="text/plain" to set the charset as well. Most of these could be left alone - the default is US-ASCII, and most of them are simple fixed US-ASCII strings - but it seemed reasonable to me to speak utf-8 everywhere.

Django will apply the encoding specified in the content_type to strings when it builds its response, so unless we're handling responses that include non-UTF-8 bytes or strings encoding characters UTF-8 can't represent, this should be safe. I didn't notice any of those, but it'd be good to check that.

Fixes #8968

Copy link

codecov bot commented Jul 10, 2025

Codecov Report

Attention: Patch coverage is 87.50000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 88.72%. Comparing base (e16d568) to head (9c21501).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
ietf/api/views.py 87.50% 1 Missing ⚠️
ietf/doc/views_ballot.py 50.00% 1 Missing ⚠️
ietf/meeting/views.py 93.75% 1 Missing ⚠️
ietf/submit/views.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9120      +/-   ##
==========================================
- Coverage   88.72%   88.72%   -0.01%     
==========================================
  Files         321      321              
  Lines       41851    41851              
==========================================
- Hits        37134    37132       -2     
- Misses       4717     4719       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

review views that return an explicitly constructed HttpResponse of type text/plain for whether they're using/declaring the appropriate encoding
1 participant