* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\EventListener; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\UriSigner; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Handles content fragments represented by special URIs. * * All URL paths starting with /_fragment are handled as * content fragments by this listener. * * If throws an AccessDeniedHttpException exception if the request * is not signed or if it is not an internal sub-request. * * @author Fabien Potencier */ class FragmentListener implements EventSubscriberInterface { private $signer; private $fragmentPath; /** * @param UriSigner $signer A UriSigner instance * @param string $fragmentPath The path that triggers this listener */ public function __construct(UriSigner $signer, $fragmentPath = '/_fragment') { $this->signer = $signer; $this->fragmentPath = $fragmentPath; } /** * Fixes request attributes when the path is '/_fragment'. * * @throws AccessDeniedHttpException if the request does not come from a trusted IP */ public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); if ($this->fragmentPath !== rawurldecode($request->getPathInfo())) { return; } if ($request->attributes->has('_controller')) { // Is a sub-request: no need to parse _path but it should still be removed from query parameters as below. $request->query->remove('_path'); return; } if ($event->isMasterRequest()) { $this->validateRequest($request); } parse_str($request->query->get('_path', ''), $attributes); $request->attributes->add($attributes); $request->attributes->set('_route_params', array_replace($request->attributes->get('_route_params', array()), $attributes)); $request->query->remove('_path'); } protected function validateRequest(Request $request) { // is the Request safe? if (!$request->isMethodSafe(false)) { throw new AccessDeniedHttpException(); } // is the Request signed? // we cannot use $request->getUri() here as we want to work with the original URI (no query string reordering) if ($this->signer->check($request->getSchemeAndHttpHost().$request->getBaseUrl().$request->getPathInfo().(null !== ($qs = $request->server->get('QUERY_STRING')) ? '?'.$qs : ''))) { return; } throw new AccessDeniedHttpException(); } public static function getSubscribedEvents() { return array( KernelEvents::REQUEST => array(array('onKernelRequest', 48)), ); } } __halt_compiler();----SIGNATURE:----Djv9unq1EtGz+TwqKBF0pmfqsI03lcFdT+RCYtC2muenSsvM8mI4uMYJxOmMnfUlpBBbpSkwJnk8fSMJ9jx3T7uh3lZdh6g5jVGvGXFOQA6KISvkpzbLcmPUqpvfN23M0npPDmACANihTIX9oxnlCS1uWWTB/FqRfXP6lo4GquTfdKTU+PM1JQi4m+F8bWbTrrUbsGTJZQ8fnrNqZd/ruoS6o2bhw6/a3z4RK3oTXxAF/AhBLm9cSoCV/4kTKoG1KMXrYSOAv7Dx4x12Tl+rmzehB0fLgobHWPr1xFSSa86VF3Li685oW8RFwfDIEyFYQsIaDIPzzaQsFSFOV2Gn0A/b2VV5UMI0Tdhbv4gYNfhzlUTE9dBL+nqREx7gQpI81Fs5HbLLimAzOeH84BCPot3TVvFduWFeu3ob9C4E3oLOVk900e7J833FAEFncrrnK7zt1hggtJl3kPdLrZi2OLV+QUp4Od9alf2fWcTbZtNqT5vLTnqVYW85F6Z30Shl+DaqaPALwu2z0a6stQ1XliSKy9WnkzQ/0EgfsEJf6CCF1+e8+buiqWfsua1t89V8CR28h8AwQBo7BB0AN8i6GH0OalKuXE0imIqE3irSEOnsveAuqXYEETB11DGjxV1lIl0RRUtaYICGmT3hWCWOOGxwsUY7Ebi2fIDVG+dUqSE=----ATTACHMENT:----MzYzMzQwMjYyNTU2NjYxMiA1NTIxNDU1MDI2MzE3MDM4IDkwMTczMTkwMTk2MzcwNTQ=