Skip to content

Commit 638f2f1

Browse files
author
Adam Otradovec
committed
fix(azure-devops): changed files with # or & in their path can be read
1 parent b7b9c8c commit 638f2f1

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎packages/source-control-azure-devops/src/server/AzureDevOpsPullRequestCli.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,22 @@ layer("AzureDevOpsPullRequestCli.layer", (it) => {
850850
}),
851851
);
852852

853+
it.effect("escapes characters in a file path that would cut the query string", () =>
854+
Effect.gen(function* () {
855+
mockedExecute.mockReturnValueOnce(Effect.succeed(output(json({ content: "x" }))));
856+
const cli = yield* AzureDevOpsPullRequestCli.AzureDevOpsPullRequestCli;
857+
858+
yield* cli.readItemContent({
859+
cwd: "/w",
860+
location: { project: "platform", repository: "web" },
861+
path: "docs/C#/a&b.md",
862+
commit: "a".repeat(40),
863+
});
864+
865+
expect(mockedExecute.mock.calls.at(-1)?.[0].args).toContain("path=%2Fdocs%2FC%23%2Fa%26b.md");
866+
}),
867+
);
868+
853869
it.effect("reports a pull request it cannot place as its own outcome", () =>
854870
Effect.gen(function* () {
855871
mockedExecute.mockReturnValueOnce(

‎packages/source-control-azure-devops/src/server/AzureDevOpsPullRequestCli.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,8 @@ export const make = Effect.gen(function* () {
603603
resource: "items",
604604
routeParameters: repositoryRoute(input.location),
605605
queryParameters: [
606-
`path=${toItemPath(input.path)}`,
606+
// `az devops invoke` does not escape query values, so `#` or `&` in a path would truncate it.
607+
`path=${encodeURIComponent(toItemPath(input.path))}`,
607608
"versionDescriptor.versionType=commit",
608609
`versionDescriptor.version=${input.commit}`,
609610
"includeContent=true",

0 commit comments

Comments
 (0)