Skip to content
Snippets Groups Projects
Commit 71cf6406 authored by Larry Garfield's avatar Larry Garfield
Browse files

Automatically urldecode() paths to allow for useful data in path fragments.

parent 2ceb9c02
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -68,6 +68,31 @@ public function onKernelRequestFrontPageResolve(GetResponseEvent $event) {
$this->setPath($request, $path);
}
/**
* Decodes the path of the request.
*
* Parameters in the URL sometimes represent code-meaningful strings. It is
* therefore useful to always urldecode() those values so that individual
* controllers need not concern themselves with it. This is Drupal-specific
* logic, and may not be familiar for developers used to other Symfony-family
* projects.
*
* @todo Revisit whether or not this logic is appropriate for here or if
* controllers should be required to implement this logic themselves. If
* we decide to keep this code, remove this TODO.
*
* @param GetResponseEvent $event
* The Event to process.
*/
public function onKernelRequestDecodePath(GetResponseEvent $event) {
$request = $event->getRequest();
$path = $this->extractPath($request);
$path = urldecode($path);
$this->setPath($request, $path);
}
/**
* Registers the methods in this class that should be listeners.
*
......@@ -75,8 +100,9 @@ public function onKernelRequestFrontPageResolve(GetResponseEvent $event) {
* An array of event listener definitions.
*/
static function getSubscribedEvents() {
$events[KernelEvents::REQUEST][] = array('onKernelRequestPathResolve', 100);
$events[KernelEvents::REQUEST][] = array('onKernelRequestDecodePath', 102);
$events[KernelEvents::REQUEST][] = array('onKernelRequestFrontPageResolve', 101);
$events[KernelEvents::REQUEST][] = array('onKernelRequestPathResolve', 100);
return $events;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment