diff --git a/modules/gitea/client.ts b/modules/gitea/client.ts index 16571f17..a087d1ec 100644 --- a/modules/gitea/client.ts +++ b/modules/gitea/client.ts @@ -793,6 +793,7 @@ export class GiteaClient { // The size first, from the file's directory listing, which carries no content: a file over what an answer can carry is // refused without its body being fetched (issue 1577). A file the listing does not show is asked for as before. const clean = path.replace(/^\/+|\/+$/g, ""); + pathSegments("file path", clean); // a path that is another path or user is refused before anything reaches the forge const slash = clean.lastIndexOf("/"); const dir = slash < 0 ? "" : clean.slice(0, slash); let listing: any[] | null = null; diff --git a/modules/gitea/test/guard.test.ts b/modules/gitea/test/guard.test.ts index 6f1431aa..295de67b 100644 --- a/modules/gitea/test/guard.test.ts +++ b/modules/gitea/test/guard.test.ts @@ -640,6 +640,7 @@ test("no tool's caller text becomes another path or another user: `..` and `?sud await tool("gitea_delete_branch").run({ ...repo, branch: "feat/x" }); await tool("gitea_get_file").run({ ...repo, path: "modules/gitea/module.json" }).catch(() => undefined); assert.deepEqual(state.asked, ["DELETE /repos/novox/mesh-catalog/branches/feat/x", + "GET /repos/novox/mesh-catalog/contents/modules/gitea", // the file's size first (issue 1577) "GET /repos/novox/mesh-catalog/contents/modules/gitea/module.json"]); });