Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
09034777
Commit
09034777
authored
Feb 07, 2013
by
Lance McNearney
Committed by
Fabien Potencier
Mar 27, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include querystring parameters when issuing a redirect from RedirectableUrlMatcher
parent
59e7dbd3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
0 deletions
+29
-0
src/Silex/Application.php
src/Silex/Application.php
+5
-0
src/Silex/RedirectableUrlMatcher.php
src/Silex/RedirectableUrlMatcher.php
+10
-0
tests/Silex/Tests/RouterTest.php
tests/Silex/Tests/RouterTest.php
+14
-0
No files found.
src/Silex/Application.php
View file @
09034777
...
...
@@ -125,6 +125,11 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
});
$this
[
'url_matcher'
]
=
$this
->
share
(
function
()
use
(
$app
)
{
// Inject the query string into the RequestContext for Symfony versions <= 2.2
if
(
$app
[
'request'
]
->
server
->
get
(
'QUERY_STRING'
)
!==
''
&&
!
method_exists
(
$app
[
'request_context'
],
'getQueryString'
))
{
$app
[
'request_context'
]
->
setParameter
(
'QUERY_STRING'
,
$app
[
'request'
]
->
server
->
get
(
'QUERY_STRING'
));
}
return
new
RedirectableUrlMatcher
(
$app
[
'routes'
],
$app
[
'request_context'
]);
});
...
...
src/Silex/RedirectableUrlMatcher.php
View file @
09034777
...
...
@@ -29,6 +29,16 @@ class RedirectableUrlMatcher extends BaseRedirectableUrlMatcher
{
$url
=
$this
->
context
->
getBaseUrl
()
.
$path
;
// Query string support was added to RequestContext in 2.3
// Fall back to parameter injected by url_matcher closure for earlier versions
$query
=
method_exists
(
$this
->
context
,
'getQueryString'
)
?
$this
->
context
->
getQueryString
()
:
$this
->
context
->
getParameter
(
'QUERY_STRING'
)
?:
''
;
if
(
$query
!==
''
)
{
$url
.=
'?'
.
$query
;
}
if
(
$this
->
context
->
getHost
())
{
if
(
$scheme
)
{
$port
=
''
;
...
...
tests/Silex/Tests/RouterTest.php
View file @
09034777
...
...
@@ -207,6 +207,20 @@ class RouterTest extends \PHPUnit_Framework_TestCase
$this
->
assertTrue
(
$response
->
isRedirect
(
'https://example.com/secured'
));
}
public
function
testRequireHttpsRedirectIncludesQueryString
()
{
$app
=
new
Application
();
$app
->
match
(
'/secured'
,
function
()
{
return
'secured content'
;
})
->
requireHttps
();
$request
=
Request
::
create
(
'http://example.com/secured?query=string'
);
$response
=
$app
->
handle
(
$request
);
$this
->
assertTrue
(
$response
->
isRedirect
(
'https://example.com/secured?query=string'
));
}
public
function
testClassNameControllerSyntax
()
{
$app
=
new
Application
();
...
...
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