Skip to content

[WebProfilerBundle] Header may not contain more than a single header, new line detected #22072

Closed
@mvar

Description

@mvar
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.2.x-dev ece42c5 (3.2.6@dev)

Hi guys, then I have invalid configuration of Sylius Resource bundle, I get this unclear exception:

Symfony\Component\Debug\Exception\ContextErrorException in Response.php line 380:
Warning: Header may not contain more than a single header, new line detected
in Response.php line 380
at Response->sendHeaders() in Response.php line 418
at Response->send() in app_dev.php line 32
at require('/Users/mantas/Sites/foo/web/app_dev.php') in router_dev.php line 40

This happens because Sylius throws exception with multiline message. I guess this happens in sub-request. I was not able to reproduce it on the main request.

WebProfilerBundle sets this message in response header:

https://github.com/symfony/symfony/blob/v3.2.6/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php#L74

$response->headers->set('X-Debug-Error', get_class($e).': '.$e->getMessage());

If I change this line like this:

$response->headers->set('X-Debug-Error', get_class($e).': '.str_replace("\n", '\n', $e->getMessage()));

Then I get message as expected:

Invalid type for path "routing.templates". Expected scalar, but got array in alias: foo.contact
grid: foo_contact
templates: [FooBundle:Crud]
(which is being imported from "/Users/mantas/Sites/foo/app/config/routing.yml").

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions