njitram
(Martijn)
September 20, 2018, 9:39am
1
When you have setup your Yii2 website i noticed when some one goes to: ‘REQUEST_URI’ => ‘/%0A’, an error is thrown; “yii\base\ErrorException: Header may not contain more than a single header, new line detected in /usr/local/php7vendor/yiisoft/yii2/web/Response.php:374” is this normal?
1 Like
CeBe
September 20, 2018, 1:29pm
2
I don’t get this error in my environment. Which server setup are you using and which version of Yii/PHP?
please also paste the full stack trace of the error.
njitram
(Martijn)
September 24, 2018, 10:04am
3
2018-09-23 20:44:10
[..][-][..][error][yii\base\ErrorException:2]
yii\base\ErrorException: Header may not contain more than a single
header, new line detected in
../vendor/yiisoft/yii2/web/Response.php:374
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleError(2, 'Header
may not ...', '/usr/local/php7...', 374, Array)
#1
../vendor/yiisoft/yii2/web/Response.php(374):
header('Location: https...', true)
#2
../vendor/yiisoft/yii2/web/Response.php(339):
yii\web\Response->sendHeaders()
#3
../vendor/yiisoft/yii2/base/Application.php(392):
yii\web\Response->send()
#4 /home/../web/index.php(25)](../web/index.php(25)):
yii\base\Application->run()
#5 {main}
2018-09-23 20:44:10
[..][-][..][info][application]
$_GET = []
$_POST = []
$_FILES = []
$_COOKIE = []
$_SESSION = [
'__flash' => []
]
$_SERVER = [
'USER' => '..'
'HOME' => '/home/..'
'HTTP_ACCEPT_ENCODING' => 'deflate, gzip'
'HTTP_ACCEPT' => '*/*'
'HTTP_USER_AGENT' => 'Mozilla/5.0 (compatible; AhrefsBot/5.2;
+http://ahrefs.com/robot/)'
'HTTP_HOST' => '[
'HTTP_REFERER' => ''
'PATH_INFO' => ''
'SCRIPT_FILENAME' =>
'/home/customer/domains/customer.nl/private_html/index.php](/private_html/index.php)'
'REDIRECT_STATUS' => '200'
'SERVER_NAME' => '[)'
'SERVER_PORT' => '443'
'SERVER_ADDR' => '..'
'REMOTE_PORT' => '44744'
'REMOTE_ADDR' => '..'
'SERVER_SOFTWARE' => 'nginx/1.13.12'
'GATEWAY_INTERFACE' => 'CGI/1.1'
'HTTPS' => 'on'
'SERVER_PROTOCOL' => 'HTTP/1.1'
'DOCUMENT_ROOT' => '/home/customer/domains/[customer.nl/private_html](http://customer.nl/private_html)'
'DOCUMENT_URI' => '/index.php'
'REQUEST_URI' => '/%0A'
'SCRIPT_NAME' => '/index.php'
'CONTENT_LENGTH' => ''
'CONTENT_TYPE' => ''
'REQUEST_METHOD' => 'GET'
'QUERY_STRING' => ''
'FCGI_ROLE' => 'RESPONDER'
'PHP_SELF' => '/index.php'
'REQUEST_TIME_FLOAT' => 1537728250.2016
'REQUEST_TIME' => 1537728250
]
Yii2 2.0.15.1
PHP 7.2.9
example here:
https://www.tpf.nu/
CeBe
September 28, 2018, 7:09am
4
Can you show your UrlManager config?
njitram
(Martijn)
October 1, 2018, 6:52am
5
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'suffix' => '/',
'normalizer' => [
'class' => 'yii\web\UrlNormalizer',
'action' => YII_DEBUG?\yii\web\UrlNormalizer::ACTION_REDIRECT_TEMPORARY:\yii\web\UrlNormalizer::ACTION_REDIRECT_PERMANENT,
],
'rules' => [
//some rules here..
],
],
ezoterik
(Oleg)
October 21, 2019, 4:22pm
6
I have the same problem. This problem is actual only if parameter enablePrettyUrl is enabled. My URL for testing:
http://mydomain.com/data:image/svg+xml,<svg%20xmlns%3d"http%3a%2f%2fwww.w3.org%2f2000%2fsvg"%20width%3d"24"%20height%3d"24">%0a%20%20<g%20fill%3d"none"%20fill-rule%3d"evenodd"%20transform%3d"translate(3%204
(I don’t know why someone tried to go to this address)
Yii2: 2.0.28
PHP: 7.1.12
yii\base\ErrorException: Header may not contain more than a single header, new line detected in /app/vendor/yiisoft/yii2/web/Response.php:374
Stack trace:
#0 /app/vendor/yiisoft/yii2/web/Response.php(374): yii\web\ErrorHandler->handleError()
#1 /app/vendor/yiisoft/yii2/web/Response.php(374): ::header()
#2 /app/vendor/yiisoft/yii2/web/Response.php(339): yii\web\Response->sendHeaders()
#3 /app/vendor/yiisoft/yii2/base/Application.php(392): yii\web\Response->send()
#4 /app/frontend/web/index.php(17): yii\web\Application->run()
#5 {main}