summaryrefslogtreecommitdiffstats
path: root/core/lib/Drupal/Core/Routing
diff options
context:
space:
mode:
authorAlex Pott2017-02-27 11:16:07 (GMT)
committerAlex Pott2017-02-27 11:16:07 (GMT)
commit7562fb24764b681e2365f8ca34dda8188e4e7247 (patch)
treeb167f77a1884da8d57e7990a0879a21ac06c218a /core/lib/Drupal/Core/Routing
parent4e8898225b052cfb0d7a1e304d4e2e76df607598 (diff)
Revert "Issue #2075889 by pwolanin, kgoel, catch, mpdonadio, YesCT, dawehner, alexpott, johnshortess, Crell, Wim Leers, jhodgdon, mradcliffe, xjm, attiks, tstoeckler, webchick: Make Drupal handle incoming paths in a case-insensitive fashion for routing"
This reverts commit 77a2431e2e5bd4c95266b0cd7da8a4f192da714a.
Diffstat (limited to 'core/lib/Drupal/Core/Routing')
-rw-r--r--core/lib/Drupal/Core/Routing/RouteCompiler.php21
-rw-r--r--core/lib/Drupal/Core/Routing/RouteProvider.php20
-rw-r--r--core/lib/Drupal/Core/Routing/RouteProviderInterface.php4
3 files changed, 13 insertions, 32 deletions
diff --git a/core/lib/Drupal/Core/Routing/RouteCompiler.php b/core/lib/Drupal/Core/Routing/RouteCompiler.php
index 52d0041..937bf48 100644
--- a/core/lib/Drupal/Core/Routing/RouteCompiler.php
+++ b/core/lib/Drupal/Core/Routing/RouteCompiler.php
@@ -2,7 +2,6 @@
namespace Drupal\Core\Routing;
-use Drupal\Component\Utility\Unicode;
use Symfony\Component\Routing\RouteCompilerInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCompiler as SymfonyRouteCompiler;
@@ -38,8 +37,7 @@ class RouteCompiler extends SymfonyRouteCompiler implements RouteCompilerInterfa
// The Drupal-specific compiled information.
$stripped_path = static::getPathWithoutDefaults($route);
$fit = static::getFit($stripped_path);
- // Store a lower-case pattern outline to enable case-insensitive matching.
- $pattern_outline = Unicode::strtolower(static::getPatternOutline($stripped_path));
+ $pattern_outline = static::getPatternOutline($stripped_path);
// We count the number of parts including any optional trailing parts. This
// allows the RouteProvider to filter candidate routes more efficiently.
$num_parts = count(explode('/', trim($route->getPath(), '/')));
@@ -48,30 +46,23 @@ class RouteCompiler extends SymfonyRouteCompiler implements RouteCompilerInterfa
$fit,
$pattern_outline,
$num_parts,
-
- // The following parameters are what Symfony uses in
- // \Symfony\Component\Routing\Matcher\UrlMatcher::matchCollection().
-
- // Set the static prefix to an empty string since it is redundant to
- // the matching in \Drupal\Core\Routing\RouteProvider::getRoutesByPath()
- // and by skipping it we more easily make the routing case insensitive.
- '',
- // Set the regex to use UTF-8 and be case-insensitive.
- $symfony_compiled->getRegex() . 'ui',
+ // These are the Symfony compiled parts.
+ $symfony_compiled->getStaticPrefix(),
+ $symfony_compiled->getRegex(),
$symfony_compiled->getTokens(),
$symfony_compiled->getPathVariables(),
$symfony_compiled->getHostRegex(),
$symfony_compiled->getHostTokens(),
$symfony_compiled->getHostVariables(),
$symfony_compiled->getVariables()
- );
+ );
}
/**
* Returns the pattern outline.
*
* The pattern outline is the path pattern but normalized so that all
- * placeholders are the string '%'.
+ * placeholders are equal strings and default values are removed.
*
* @param string $path
* The path for which we want the normalized outline.
diff --git a/core/lib/Drupal/Core/Routing/RouteProvider.php b/core/lib/Drupal/Core/Routing/RouteProvider.php
index 4586652..53ed626 100644
--- a/core/lib/Drupal/Core/Routing/RouteProvider.php
+++ b/core/lib/Drupal/Core/Routing/RouteProvider.php
@@ -5,7 +5,6 @@ namespace Drupal\Core\Routing;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
-use Drupal\Component\Utility\Unicode;
use Drupal\Core\Path\CurrentPathStack;
use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
use Drupal\Core\State\StateInterface;
@@ -140,9 +139,7 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv
*
* @return \Symfony\Component\Routing\RouteCollection with all urls that
* could potentially match $request. Empty collection if nothing can
- * match. The collection will be sorted from highest to lowest fit (match
- * of path parts) and then in ascending order by route name for routes
- * with the same fit.
+ * match.
*/
public function getRouteCollectionForRequest(Request $request) {
// Cache both the system path as well as route parameters and matching
@@ -320,19 +317,15 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv
* Get all routes which match a certain pattern.
*
* @param string $path
- * The route pattern to search for.
+ * The route pattern to search for (contains % as placeholders).
*
* @return \Symfony\Component\Routing\RouteCollection
- * Returns a route collection of matching routes. The collection may be
- * empty and will be sorted from highest to lowest fit (match of path parts)
- * and then in ascending order by route name for routes with the same fit.
+ * Returns a route collection of matching routes.
*/
protected function getRoutesByPath($path) {
// Split the path up on the slashes, ignoring multiple slashes in a row
- // or leading or trailing slashes. Convert to lower case here so we can
- // have a case insensitive match from the incoming path to the lower case
- // pattern outlines from \Drupal\Core\Routing\RouteCompiler::compile().
- $parts = preg_split('@/+@', Unicode::strtolower($path), NULL, PREG_SPLIT_NO_EMPTY);
+ // or leading or trailing slashes.
+ $parts = preg_split('@/+@', $path, NULL, PREG_SPLIT_NO_EMPTY);
$collection = new RouteCollection();
@@ -354,8 +347,7 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv
$routes = [];
}
- // We sort by fit and name in PHP to avoid a SQL filesort and avoid any
- // difference in the sorting behavior of SQL back-ends.
+ // We sort by fit and name in PHP to avoid a SQL filesort.
usort($routes, array($this, 'routeProviderRouteCompare'));
foreach ($routes as $row) {
diff --git a/core/lib/Drupal/Core/Routing/RouteProviderInterface.php b/core/lib/Drupal/Core/Routing/RouteProviderInterface.php
index f53593a..ce07a6d 100644
--- a/core/lib/Drupal/Core/Routing/RouteProviderInterface.php
+++ b/core/lib/Drupal/Core/Routing/RouteProviderInterface.php
@@ -18,9 +18,7 @@ interface RouteProviderInterface extends RouteProviderBaseInterface {
* The route pattern to search for (contains {} as placeholders).
*
* @return \Symfony\Component\Routing\RouteCollection
- * Returns a route collection of matching routes. The collection may be
- * empty and will be sorted from highest to lowest fit (match of path parts)
- * and then in ascending order by route name for routes with the same fit.
+ * Returns a route collection of matching routes.
*/
public function getRoutesByPattern($pattern);