Skip to content

Commit a3a9225

Browse files
oleksandr-ncbackportbot[bot]
authored andcommitted
fix(proxy): add transitional bare-path fallback for legacy route URLs
Signed-off-by: Oleksander Piskun <oleksandr2088@icloud.com>
1 parent 5d3ed63 commit a3a9225

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

lib/Controller/ExAppProxyController.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,19 @@ private function buildMultipartFormData(array $bodyParams, array $files): array
318318

319319
private function passesExAppProxyRoutesChecks(ExApp $exApp, string $exAppRoute): array {
320320
// Route URL is a regex matched against the request path including its leading slash, mirroring HaRP's target_path semantics.
321-
$exAppRoute = '/' . $exAppRoute;
321+
$canonicalSubject = '/' . $exAppRoute;
322322
foreach ($exApp->getRoutes() as $route) {
323323
$pattern = '~^(?:' . str_replace('~', '\\~', $route['url']) . ')~i';
324-
if (preg_match($pattern, $exAppRoute) === 1
324+
$matched = preg_match($pattern, $canonicalSubject) === 1;
325+
if (!$matched && preg_match($pattern, $exAppRoute) === 1) {
326+
// TODO(deprecation): remove this bare-path fallback once known ExApps have migrated their info.xml route URLs to the canonical `^/path$` form. Tracked by the AppAPI / context_chat_backend coordination effort.
327+
$this->logger->debug(sprintf(
328+
'ExApp "%s" matched route "%s" via legacy bare-path fallback. Update the info.xml route URL to start with "/" or "^/" so it matches against "%s".',
329+
$exApp->getAppid(), $route['url'], $canonicalSubject
330+
));
331+
$matched = true;
332+
}
333+
if ($matched
325334
&& str_contains(strtolower($route['verb']), strtolower($this->request->getMethod()))
326335
) {
327336
// First match by path+verb wins. Apply its access level without falling through to broader routes.

0 commit comments

Comments
 (0)