monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

[Bug] Custom link scheme is not detected as link in markdown

Open yanny7 opened this issue 2 years ago • 3 comments

Reproducible in vscode.dev or in VS Code Desktop?

  • [X] Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.44.0#XQAAAALJAQAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscwz-7R8SSBllIQYhbGzKaw9s6TTaSvbNyeizCvxyxeq65_r5IM0tVdxL9ULPfJTLudi4DID0IWzphTyPnD0qlcJAVQ5wNfnBcBqeWaoH_bWyIqmZSdTne9kB1shOrZhaSw7OzegCvsTNnhSBJysGpmtQKShNZOXhI3pOcHndnvUYYRD9ipmwkYHnLMBTE5j8kFkYO9Qg9RVsPk7cIRB7X9T91crGMsld5olM872Hm5weeuk4kmiI9UY9ZFXhyQqfb-D8Fc_zJc6gsEC741t4o2OisOOR7WeiDHgjPOHPzeFpIdb73CqwUMx6x7qlGx3Cv-9wrbjA

Monaco Editor Playground Code

monaco.languages.register({ id: "mySpecialLanguage" });

monaco.languages.registerHoverProvider("mySpecialLanguage", {
	provideHover: function () {
			return {
				contents: [
					{ value: "**SOURCE** [ClickMe](test://google.com)" },
				],
			};
	},
});

monaco.editor.create(document.getElementById("container"), {
	value: "\n\nHover over this text",
	language: "mySpecialLanguage",
});

Reproduction Steps

hover over text

Actual (Problematic) Behavior

hover text is not clickable

Expected Behavior

link provided via markdown is clickable

Additional Context

Last working version - 0.33.0

yanny7 avatar Oct 26 '23 13:10 yanny7

@mjbvz Afaik you worked on MarkdownString. It seems like all "dangerous" markup is stripped from the hover. Do you know why?

hediet avatar Dec 13 '23 16:12 hediet

The hover contents often come from untrusted sources (such as rendering JSDocs taken from a package on npm). We strip out unsafe html and unknown link schemes as these can be used to trigger potentially unwanted actions on the user's machine (I believe modern browsers now show a confirmation dialog before opening app links but this wasn't always the case)

Here's the allow list of schemes: https://github.com/microsoft/vscode/blob/cbab473f37e65d2fabbc4b07d45baec5bb271e47/src/vs/base/browser/markdownRenderer.ts#L428

mjbvz avatar Dec 13 '23 19:12 mjbvz

@mjbvz From provided list Data schema doesn't work.

Should be great if there is way to override this behavior or provide list of custom supported schema

yanny7 avatar Dec 14 '23 06:12 yanny7