Skip to content

Commit 0dc3729

Browse files
committed
fix(server): redact queries after quoted clone paths
1 parent d71e4a7 commit 0dc3729

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎apps/server/src/sourceControl/SourceControlRepositoryService.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,15 @@ it.effect.each([
390390
["a host-only token with an at sign", "abc@secret"],
391391
["an unquoted token with an apostrophe", "s3'cret", true],
392392
["an unquoted token with a double quote", 's3"cret', true],
393+
["an unquoted URL with an apostrophe in its path", "path-token", true],
393394
] as const)("keeps %s in the query out of a failed clone's error text", ([, token, unquoted]) =>
394395
Effect.gen(function* () {
395396
const remote =
396-
token === "abc@secret" ? "https://github.com" : "https://github.com/octocat/t3code.git";
397+
token === "abc@secret"
398+
? "https://github.com"
399+
: token === "path-token"
400+
? "https://github.com/octocat/t3code's.git"
401+
: "https://github.com/octocat/t3code.git";
397402
const error = yield* Effect.flip(
398403
cloneInTemporaryDirectory(
399404
{

‎apps/server/src/sourceControl/SourceControlRepositoryService.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function redactRemoteUrl(remoteUrl: string): string {
131131
const URL_WITH_USERINFO = /\b([a-z][a-z0-9+.-]*:\/\/)[^\s/?#]+@/gi;
132132
// Git leaves quotes inside query tokens unescaped; consume through the closing quote.
133133
const QUOTED_URL_QUERY = /(['"])([a-z][a-z0-9+.-]*:\/\/[^\s?]*)\?.*\1(?=[\s:]|$)/gi;
134-
const URL_QUERY = /\b([a-z][a-z0-9+.-]*:\/\/[^\s?'"]*)\?[^\s]*/gi;
134+
const URL_QUERY = /\b([a-z][a-z0-9+.-]*:\/\/[^\s?]*)\?[^\s]*/gi;
135135

136136
function redactUrlCredentials(text: string): string {
137137
return text

0 commit comments

Comments
 (0)