mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Refactor URL parameter matching in OpenAPI3 and Swagger2 to improve path parameter detection by checking for trailing characters.
This commit is contained in:
@@ -758,9 +758,17 @@ class OpenAPI3 extends Format
|
||||
$pathAliases = [$name, ...($param['aliases'] ?? [])];
|
||||
$isPathParam = false;
|
||||
foreach ($pathAliases as $pathAlias) {
|
||||
if (false !== \strpos($url, ':' . $pathAlias)) {
|
||||
$isPathParam = true;
|
||||
break;
|
||||
$pathNeedle = ':' . $pathAlias;
|
||||
$offset = 0;
|
||||
|
||||
while (false !== ($position = \strpos($url, $pathNeedle, $offset))) {
|
||||
$nextChar = $url[$position + \strlen($pathNeedle)] ?? '';
|
||||
if ($nextChar === '' || $nextChar === '/') {
|
||||
$isPathParam = true;
|
||||
break 2;
|
||||
}
|
||||
|
||||
$offset = $position + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -725,9 +725,17 @@ class Swagger2 extends Format
|
||||
$pathAliases = [$name, ...($param['aliases'] ?? [])];
|
||||
$isPathParam = false;
|
||||
foreach ($pathAliases as $pathAlias) {
|
||||
if (\str_contains($url, ':' . $pathAlias)) {
|
||||
$isPathParam = true;
|
||||
break;
|
||||
$pathNeedle = ':' . $pathAlias;
|
||||
$offset = 0;
|
||||
|
||||
while (false !== ($position = \strpos($url, $pathNeedle, $offset))) {
|
||||
$nextChar = $url[$position + \strlen($pathNeedle)] ?? '';
|
||||
if ($nextChar === '' || $nextChar === '/') {
|
||||
$isPathParam = true;
|
||||
break 2;
|
||||
}
|
||||
|
||||
$offset = $position + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user