Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
25ad826d
Commit
25ad826d
authored
Jul 04, 2014
by
Philippe Gaultier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix multiple headers management in Access-Control-Request-Headers
parent
f31bfd1f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
Cors.php
framework/filters/Cors.php
+8
-5
No files found.
framework/filters/Cors.php
View file @
25ad826d
...
...
@@ -179,9 +179,9 @@ class Cors extends ActionFilter
if
(
isset
(
$requestHeaders
[
$requestHeaderField
]))
{
if
(
in_array
(
'*'
,
$this
->
cors
[
$requestHeaderField
]))
{
if
(
$type
===
'Method'
)
{
$responseHeaders
[
$responseHeaderField
]
=
strtoupper
(
$re
sponseHeaders
[
$response
HeaderField
]);
$responseHeaders
[
$responseHeaderField
]
=
strtoupper
(
$re
questHeaders
[
$request
HeaderField
]);
}
elseif
(
$type
===
'Headers'
)
{
$responseHeaders
[
$responseHeaderField
]
=
static
::
headerize
(
$re
sponseHeaders
[
$response
HeaderField
]);
$responseHeaders
[
$responseHeaderField
]
=
static
::
headerize
(
$re
questHeaders
[
$request
HeaderField
]);
}
}
else
{
$requestedData
=
preg_split
(
"/[\s,]+/"
,
$requestHeaders
[
$requestHeaderField
],
-
1
,
PREG_SPLIT_NO_EMPTY
);
...
...
@@ -190,7 +190,6 @@ class Cors extends ActionFilter
if
(
$type
===
'Method'
)
{
$req
=
strtoupper
(
$req
);
}
elseif
(
$type
===
'Headers'
)
{
// ucwords
$req
=
static
::
headerize
(
$req
);
}
if
(
in_array
(
$req
,
$this
->
cors
[
$requestHeaderField
]))
{
...
...
@@ -222,13 +221,17 @@ class Cors extends ActionFilter
/**
* Convert any string (including php headers with HTTP prefix) to header format like :
* * X-PINGOTHER -> X-Pingother
* *
HTTP_
X_PINGOTHER -> X-Pingother
* * X_PINGOTHER -> X-Pingother
* @param string $string string to convert
* @return string the result in "header" format
*/
protected
static
function
headerize
(
$string
)
{
return
str_replace
(
' '
,
'-'
,
ucwords
(
strtolower
(
str_replace
([
'_'
,
'-'
],
[
' '
,
' '
],
$string
))));
$headers
=
preg_split
(
"/[\s,]+/"
,
$string
,
-
1
,
PREG_SPLIT_NO_EMPTY
);
$headers
=
array_map
(
function
(
$element
)
{
return
str_replace
(
' '
,
'-'
,
ucwords
(
strtolower
(
str_replace
([
'_'
,
'-'
],
[
' '
,
' '
],
$element
))));
},
$headers
);
return
implode
(
', '
,
$headers
);
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment