Skip to content

errors with newlines #115

@drifteaur

Description

@drifteaur

If Element API catches an exception, it will output the exception's message as a HTTP header. The exception message can contain newlines, in which case Yii will print an unhelpful message instead of the exception's message:

PHP Warning 'yii\base\ErrorException' with message 'Header may not contain more than a single header, new line detected' 

in /Users/drifter/www/project/vendor/yiisoft/yii2/web/Response.php:380

Stack trace:
#0 /Users/drifter/www/project/vendor/yiisoft/yii2/web/Response.php(380): ::header()
#1 /Users/drifter/www/project/vendor/yiisoft/yii2/web/Response.php(339): craft\web\Response->sendHeaders()
#2 /Users/drifter/www/project/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Response->send()
#3 /Users/drifter/www/project/web/index.php(86): craft\web\Application->run()
#4 {main}

Proposed resolution: don't include the error message in the header text (it's already included in the content of the returned data). Or, remove the newlines.

It's in DefaultController.php at around line 170.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions