ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ShortlinkRequestBuilder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28
33{
34 public function buildRequest(GlobalHttpState $http, Factory $refinery, array $handlers): ?Request
35 {
36 // Legacy permanent links always carry a "target" query parameter: either because
37 // they were requested as goto.php?target=... directly, or because the rewrite rules
38 // shipped in components/ILIAS/Init/resources/.htaccess turn
39 // /goto_<client_id>_<type>_<id>.html into goto.php?client_id=...&target=... .
40 // Such a rewrite is server-internal, so REQUEST_URI - and therefore the path below -
41 // still reads /goto_<client_id>_<type>_<id>.html and none of the goto.php/go checks
42 // match. Without this guard these requests would be captured here and answered with
43 // a 404 by the shortlink handler. They belong to the LegacyRequestBuilder, which
44 // keys on exactly the same query parameter.
45 if ($http->wrapper()->query()->has(LegacyGotoHandler::TARGET)) {
46 return null;
47 }
48
49 $requested_url = $http->request()->getUri()->getPath();
50
51 if (
52 str_contains($requested_url, StandardURIBuilder::SHORT)
53 || str_contains($requested_url, StandardURIBuilder::LONG)
54 || str_contains($requested_url, rtrim(StandardURIBuilder::LONG, '/'))
55 ) {
56 return null;
57 }
58
59
60 return new Request(
62 null,
63 [basename($requested_url)]
64 );
65 }
66}
Builds data types.
Definition: Factory.php:36
buildRequest(GlobalHttpState $http, Factory $refinery, array $handlers)
Interface GlobalHttpState.