Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
252448a0
Verified
Commit
252448a0
authored
6 months ago
by
Lee Rowlands
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3489329
by mfb, casey: symfony/http-foundation commit 32310ff breaks PathValidator
(cherry picked from commit
90ab4e3d
)
parent
0aeedd16
No related branches found
No related tags found
1 merge request
!12235
3526426-warning-for-missing
Pipeline
#351680
passed
6 months ago
Stage: 🪄 Lint
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/lib/Drupal/Core/Path/PathValidator.php
+10
-1
10 additions, 1 deletion
core/lib/Drupal/Core/Path/PathValidator.php
core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php
+16
-0
16 additions, 0 deletions
core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php
with
26 additions
and
1 deletion
core/lib/Drupal/Core/Path/PathValidator.php
+
10
−
1
View file @
252448a0
...
...
@@ -10,6 +10,7 @@
use
Drupal\Core\Session\AccountInterface
;
use
Drupal\Core\Url
;
use
Drupal\Core\Routing\RouteObjectInterface
;
use
Symfony\Component\HttpFoundation\Exception\BadRequestException
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
;
use
Symfony\Component\Routing\Exception\MethodNotAllowedException
;
...
...
@@ -118,7 +119,12 @@ protected function getUrl($path, $access_check) {
return
Url
::
fromUri
(
$path
);
}
$request
=
Request
::
create
(
'/'
.
$path
);
try
{
$request
=
Request
::
create
(
'/'
.
$path
);
}
catch
(
BadRequestException
)
{
return
FALSE
;
}
$attributes
=
$this
->
getPathAttributes
(
$path
,
$request
,
$access_check
);
if
(
!
$attributes
)
{
...
...
@@ -172,6 +178,9 @@ protected function getPathAttributes($path, Request $request, $access_check) {
catch
(
MethodNotAllowedException
$e
)
{
$result
=
FALSE
;
}
catch
(
BadRequestException
)
{
$result
=
FALSE
;
}
$router
->
setContext
(
$initial_request_context
);
return
$result
;
...
...
This diff is collapsed.
Click to expand it.
core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php
+
16
−
0
View file @
252448a0
...
...
@@ -444,4 +444,20 @@ public function testGetUrlIfValidWithoutAccessCheck(): void {
$this
->
assertEquals
([
'key'
=>
'value'
],
$url
->
getRouteParameters
());
}
/**
* Tests the getUrlIfValidWithoutAccessCheck() method with an invalid path.
*
* @covers ::getUrlIfValidWithoutAccessCheck
* @covers ::getUrl
*/
public
function
testGetUrlIfValidWithoutAccessCheckWithInvalidPath
():
void
{
// URLs must not start nor end with ASCII control characters or spaces.
$this
->
assertFalse
(
$this
->
pathValidator
->
getUrlIfValidWithoutAccessCheck
(
'foo '
));
// Also check URL-encoded variant.
$this
->
pathProcessor
->
expects
(
$this
->
once
())
->
method
(
'processInbound'
)
->
willReturnArgument
(
0
);
$this
->
assertFalse
(
$this
->
pathValidator
->
getUrlIfValidWithoutAccessCheck
(
'foo%20'
));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment