Skip to content

vscode.git: Poorly rendered author line when author name contains special characters or Markdown #255009

@CSharperMantle

Description

@CSharperMantle

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.101.2
  • OS Version: Microsoft Windows [Version 10.0.26120.4520]

Steps to Reproduce

Run the commands:

> mkdir test_repo
> cd test_repo\
> git init
Initialized empty Git repository in [path]
> git config --local user.name 'Test "Quoted" Name'
> git config --local user.email '[email protected]'
> touch test_file
> git add .
> git commit -m "Test commit"
[main (root-commit) 56543c4] Test commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test_file
> code .
>

Then go to "Source Control > Graph", hover over the commit and observe the poorly-rendered mailto: links and names.

Screenshot

Extra notes

The problem might be that the Markdown to be rendered is directly interpolated without special quoting for the "author" and "email" fields:

setItemDetails(uri: Uri, hash: string | undefined, shortHash: string | undefined, avatar: string | undefined, author: string, email: string | undefined, date: string, message: string, shortStat?: CommitShortStat, remoteSourceCommands: Command[] = []): void {
this.tooltip = new MarkdownString('', true);
this.tooltip.isTrusted = true;
const avatarMarkdown = avatar
? `![${author}](${avatar}|width=${AVATAR_SIZE},height=${AVATAR_SIZE})`
: '$(account)';
if (email) {
const emailTitle = l10n.t('Email');
this.tooltip.appendMarkdown(`${avatarMarkdown} [**${author}**](mailto:${email} "${emailTitle} ${author}")`);
} else {
this.tooltip.appendMarkdown(`${avatarMarkdown} **${author}**`);
}

If we modify the author name to be a image link, e.g. Test ![user](https://csmantle.top/favicon.ico|width=256,height=256), we can make VSCode render an image in the author line.

> git config --local user.name 'Test ![user](https://csmantle.top/favicon.ico|width=256,height=256)'
> touch test_1
> git add .
> git commit -m "Test commit 1"
[main d6d0054] Test commit 1
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test_1
> code .
> 
Image

Edit: Since vscode.git is built-in, disabling all extensions does not invalidate this issue.

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable buggitGIT issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions