ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\StaticURL\Request\ShortlinkRequestBuilder Class Reference
+ Inheritance diagram for ILIAS\StaticURL\Request\ShortlinkRequestBuilder:
+ Collaboration diagram for ILIAS\StaticURL\Request\ShortlinkRequestBuilder:

Public Member Functions

 buildRequest (GlobalHttpState $http, Factory $refinery, array $handlers)
 
 buildRequest (GlobalHttpState $http, Factory $refinery, array $handlers)
 

Detailed Description

Member Function Documentation

◆ buildRequest()

ILIAS\StaticURL\Request\ShortlinkRequestBuilder::buildRequest ( GlobalHttpState  $http,
Factory  $refinery,
array  $handlers 
)

Implements ILIAS\StaticURL\Request\RequestBuilder.

Definition at line 34 of file ShortlinkRequestBuilder.php.

34 : ?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 }

References ILIAS\BookingManager\Common\Table\$http, ILIAS\BookingManager\Common\HttpService\has(), ILIAS\StaticURL\Builder\StandardURIBuilder\LONG, ILIAS\StaticURL\Builder\StandardURIBuilder\SHORT, ILIAS\StaticURL\Shortlinks\Handler\SHORTLINK_NAMESPACE, and ILIAS\StaticURL\Handler\LegacyGotoHandler\TARGET.

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: