Skip to content

Commit

Permalink
Fixes netbox-community#544: Strip CRLF-style line terminators from re…
Browse files Browse the repository at this point in the history
…ndered export templates
  • Loading branch information
jeremystretch committed Sep 12, 2016
1 parent cd6b856 commit 18418f9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions netbox/extras/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ def to_response(self, context_dict, filename):
"""
template = Template(self.template_code)
mime_type = 'text/plain' if not self.mime_type else self.mime_type
response = HttpResponse(
template.render(Context(context_dict)),
content_type=mime_type
)
output = template.render(Context(context_dict))
# Replace CRLF-style line terminators
output = output.replace('\r\n', '\n')
response = HttpResponse(output, content_type=mime_type)
if self.file_extension:
filename += '.{}'.format(self.file_extension)
response['Content-Disposition'] = 'attachment; filename="{}"'.format(filename)
Expand Down

0 comments on commit 18418f9

Please sign in to comment.