Skip to content

Commit 2f54511

Browse files
committed
Changed all explicitly set HttpResponse content_types to specify charset.
Django sets charset if you don't specify a content_type; if you specify one you also must add a charset specification (if you want one). Fixes issue ietf-tools#1647. - Legacy-Id: 9348
1 parent 73664a4 commit 2f54511

6 files changed

Lines changed: 14 additions & 8 deletions

File tree

ietf/doc/views_charter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,4 +735,4 @@ def charter_with_milestones_txt(request, name, rev):
735735
dict(charter_text=charter_text,
736736
milestones=milestones),
737737
context_instance=RequestContext(request),
738-
content_type="text/plain")
738+
content_type="text/plain; charset=%s"%settings.DEFAULT_CHARSET)

ietf/iesg/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def agenda_txt(request, date=None):
192192
"date": data["date"],
193193
"sections": sorted(data["sections"].iteritems()),
194194
"domain": Site.objects.get_current().domain,
195-
}, context_instance=RequestContext(request), content_type="text/plain")
195+
}, context_instance=RequestContext(request), content_type="text/plain; charset=%s"%settings.DEFAULT_CHARSET)
196196

197197
def agenda_scribe_template(request, date=None):
198198
data = agenda_data(date)

ietf/ipr/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ def iprs_for_drafts_txt(request):
482482
for name, iprs in docipr.iteritems():
483483
lines.append(name + "\t" + "\t".join(unicode(ipr_id) for ipr_id in sorted(iprs)))
484484

485-
return HttpResponse("\n".join(lines), content_type="text/plain")
485+
return HttpResponse("\n".join(lines), content_type="text/plain; charset=%s"%settings.DEFAULT_CHARSET)
486486

487487
def new(request, type, updates=None):
488488
"""Submit a new IPR Disclosure. If the updates field != None, this disclosure

ietf/meeting/views.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,12 @@ def agenda(request, num=None, name=None, base=None, ext=None):
365365
ext = ext if ext else '.html'
366366
if 'iPhone' in get_user_agent(request) and ext == ".html":
367367
base = 'm_agenda'
368-
mimetype = {".html":"text/html", ".txt": "text/plain", ".ics":"text/calendar", ".csv":"text/csv"}
368+
mimetype = {
369+
".html":"text/html; charset=%s"%settings.DEFAULT_CHARSET,
370+
".txt": "text/plain; charset=%s"%settings.DEFAULT_CHARSET,
371+
".ics":"text/calendar; charset=%s"%settings.DEFAULT_CHARSET,
372+
".csv":"text/csv; charset=%s"%settings.DEFAULT_CHARSET,
373+
}
369374
meeting = get_meeting(num)
370375
schedule = get_schedule(meeting, name)
371376
if schedule == None:
@@ -404,7 +409,7 @@ def session_agenda(request, num, session):
404409
ext = ext.lstrip(".").lower()
405410

406411
if ext == "txt":
407-
return HttpResponse(content, content_type="text/plain")
412+
return HttpResponse(content, content_type="text/plain; charset=%s"%settings.DEFAULT_CHARSET)
408413
elif ext == "pdf":
409414
return HttpResponse(content, content_type="application/pdf")
410415
else:

ietf/secr/groups/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from django.contrib import messages
2+
from django.conf import settings
23
from django.forms.models import inlineformset_factory
34
from django.shortcuts import render_to_response, get_object_or_404, redirect
45
from django.template import RequestContext
@@ -144,7 +145,7 @@ def blue_dot(request):
144145

145146
return render_to_response('groups/blue_dot_report.txt', {
146147
'chairs':sorted_chairs},
147-
RequestContext(request, {}), content_type="text/plain",
148+
RequestContext(request, {}), content_type="text/plain; charset=%s"%settings.DEFAULT_CHARSET,
148149
)
149150

150151
@role_required('Secretariat')

ietf/sync/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ def runscript(name):
9696
failed, out = runscript("rfc-editor-index-updates")
9797

9898
if failed:
99-
return HttpResponseServerError("FAIL\n\n" + out, content_type="text/plain")
99+
return HttpResponseServerError("FAIL\n\n" + out, content_type="text/plain; charset=%s"%settings.DEFAULT_CHARSET)
100100
else:
101-
return HttpResponse("OK", content_type="text/plain")
101+
return HttpResponse("OK", content_type="text/plain; charset=%s"%settings.DEFAULT_CHARSET)
102102

103103
return render_to_response('sync/notify.html',
104104
dict(org=known_orgs[org],

0 commit comments

Comments
 (0)