Skip to content

Git extension askpass https host parsed incorrectly #117152

Closed
@sargreal

Description

@sargreal
  • VS Code Version: 1.53.2
  • OS Version: Manjaro unstable
  • Git Version: 2.30.1

Steps to Reproduce:

  1. Execute git.clone command
  2. Enter https git url for a private repository (does not even need to exist, so for example https://gitlab.com/haasef/test.git)
  3. Askpass pops up with Git: https://gitlab.com': (Press 'Enter' ...) (The last two characters ': are from the host string and not the template)

Why is this an issue?

  1. It does not create a problem when using the direct clone or github credentials provider (since that one does not check equality but only if github.com is contained)
  2. But: when adding a new credentials provider that checks for the explicit url, it fails (see gitlab-vscode-extension)
  3. This should have been fixed in Sometimes Git can't authenticate against GitHub #115037 but the fix does not handle a : in the end

More Information:

  • askpass-main recieves:
    [
      "/home/felix/Documents/coding/vscode/.build/electron/code-oss",
      "/home/felix/Documents/coding/vscode/extensions/git/out/askpass-main.js",
      "Username",
      "for",
      "'https://gitlab.com':",
    ]
    
  • and parses the host as https://gitlab.com': instead of https://gitlab.com

Suggested fix:

diff --git a/extensions/git/src/askpass-main.ts b/extensions/git/src/askpass-main.ts
index c15dd583fa..f17dc63463 100644
--- a/extensions/git/src/askpass-main.ts
+++ b/extensions/git/src/askpass-main.ts
@@ -30,7 +30,7 @@ function main(argv: string[]): void {
 
        const output = process.env['VSCODE_GIT_ASKPASS_PIPE'] as string;
        const request = argv[2];
-       const host = argv[4].replace(/^["']+|["']+$/g, '');
+       const host = argv[4].replace(/^["']+|["':]+$/g, '');
        const ipcClient = new IPCClient('askpass');
 
        ipcClient.call({ request, host }).then(res => {

Does this issue occur when all extensions are disabled?: Yes (Was tested and debugged on master)

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable buggitGIT issuesinsiders-releasedPatch has been released in VS Code InsidersverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions