Example #1
0
 /**
  * Inspects the request and determines what to serve.
  */
 public function dispatch(Request $request)
 {
     // This is a crappy place for this, but it has to come AFTER the packages because sometimes packages
     // want to replace legacy "tools" URLs with the new MVC, and the tools paths are so greedy they don't
     // work unless they come at the end.
     $this->registerLegacyRoutes();
     $path = rawurldecode($request->getPathInfo());
     if (substr($path, 0, 3) == '../' || substr($path, -3) == '/..' || strpos($path, '/../') || substr($path, 0, 3) == '..\\' || substr($path, -3) == '\\..' || strpos($path, '\\..\\')) {
         throw new \RuntimeException(t('Invalid path traversal. Please make this request with a valid HTTP client.'));
     }
     if ($this->installed) {
         $response = $this->getEarlyDispatchResponse();
     }
     if (!isset($response)) {
         $collection = Route::getList();
         $context = new \Symfony\Component\Routing\RequestContext();
         $context->fromRequest($request);
         $matcher = new UrlMatcher($collection, $context);
         $path = rtrim($request->getPathInfo(), '/') . '/';
         try {
             $request->attributes->add($matcher->match($path));
             $matched = $matcher->match($path);
             $route = $collection->get($matched['_route']);
             Route::setRequest($request);
             $response = Route::execute($route, $matched);
         } catch (ResourceNotFoundException $e) {
             $callback = new DispatcherRouteCallback('dispatcher');
             $response = $callback->execute($request);
         }
     }
     return $response;
 }
Example #2
0
 /**
  * Inspects the request and determines what to serve.
  */
 public function dispatch(Request $request)
 {
     if ($this->installed) {
         $response = $this->getEarlyDispatchResponse();
     }
     if (!isset($response)) {
         $collection = Route::getList();
         $context = new \Symfony\Component\Routing\RequestContext();
         $context->fromRequest($request);
         $matcher = new UrlMatcher($collection, $context);
         $path = rtrim($request->getPathInfo(), '/') . '/';
         try {
             $request->attributes->add($matcher->match($path));
             $matched = $matcher->match($path);
             $route = $collection->get($matched['_route']);
             Route::setRequest($request);
             $response = Route::execute($route, $matched);
         } catch (ResourceNotFoundException $e) {
             $callback = new DispatcherRouteCallback('dispatcher');
             $response = $callback->execute($request);
         }
     }
     return $response;
 }