mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 17:08:41 -06:00
Fixes #544: Strip CRLF-style line terminators from rendered export templates
This commit is contained in:
parent
ca6c62facd
commit
99510a990a
@ -234,10 +234,10 @@ class ExportTemplate(models.Model):
|
|||||||
"""
|
"""
|
||||||
template = Template(self.template_code)
|
template = Template(self.template_code)
|
||||||
mime_type = 'text/plain' if not self.mime_type else self.mime_type
|
mime_type = 'text/plain' if not self.mime_type else self.mime_type
|
||||||
response = HttpResponse(
|
output = template.render(Context(context_dict))
|
||||||
template.render(Context(context_dict)),
|
# Replace CRLF-style line terminators
|
||||||
content_type=mime_type
|
output = output.replace('\r\n', '\n')
|
||||||
)
|
response = HttpResponse(output, content_type=mime_type)
|
||||||
if self.file_extension:
|
if self.file_extension:
|
||||||
filename += '.{}'.format(self.file_extension)
|
filename += '.{}'.format(self.file_extension)
|
||||||
response['Content-Disposition'] = 'attachment; filename="{}"'.format(filename)
|
response['Content-Disposition'] = 'attachment; filename="{}"'.format(filename)
|
||||||
|
Loading…
Reference in New Issue
Block a user