Skip to content

download_annotation BadHeaderError: Header values can't contain newlines #671

@will-moore

Description

@will-moore

From QA https://qa.openmicroscopy.org/qa/feedback/92459/

< DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Traceback (most recent call last):

File "/opt/omero/web/venv-3.12/lib64/python3.12/site-packages/django/http/response.py", line 57, in _convert_to_charset
value.encode(charset)

UnicodeEncodeError: 'latin-1' codec can't encode character '\u2013' in position 33: ordinal not in range(256)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "/opt/omero/web/venv-3.12/lib64/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^

File "/opt/omero/web/venv-3.12/lib64/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/opt/omero/web/venv-3.12/lib64/python3.12/site-packages/omeroweb/decorators.py", line 538, in wrapped
retval = f(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/opt/omero/web/venv-3.12/lib64/python3.12/site-packages/omeroweb/webclient/views.py", line 3375, in download_annotation
rsp["Content-Disposition"] = "attachment; filename=%s" % (
~~~^^^^^^^^^^^^^^^^^^^^^^^

File "/opt/omero/web/venv-3.12/lib64/python3.12/site-packages/django/http/response.py", line 198, in __setitem__
self.headers[header] = value
~~~~~~~~~~~~^^^^^^^^

File "/opt/omero/web/venv-3.12/lib64/python3.12/site-packages/django/http/response.py", line 92, in __setitem__
value = self._convert_to_charset(value, "latin-1", mime_encode=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/opt/omero/web/venv-3.12/lib64/python3.12/site-packages/django/http/response.py", line 77, in _convert_to_charset
raise BadHeaderError(

django.http.response.BadHeaderError: Header values can't contain newlines (got 'attachment; filename=01_May_2026_–_iPCs_ICC_+_PLA\r\niPSCs_NDUF4_–_Corrected_\r\n.pdf')

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions