diff --git a/src/sql/workbench/contrib/notebook/browser/outputs/notebookMarkdown.ts b/src/sql/workbench/contrib/notebook/browser/outputs/notebookMarkdown.ts index e6f117b5a2..0ce353de9a 100644 --- a/src/sql/workbench/contrib/notebook/browser/outputs/notebookMarkdown.ts +++ b/src/sql/workbench/contrib/notebook/browser/outputs/notebookMarkdown.ts @@ -134,11 +134,16 @@ export class NotebookMarkdownRenderer { } else { // HTML Encode href - href = href.replace(/&(?!amp;)/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); + let uri = URI.parse(href); + // mailto uris do not need additional encoding of &, otherwise it would not render properly + if (uri.scheme !== 'mailto') { + href = href.replace(/&(?!amp;)/g, '&'); + } else { + href = href.replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + } return `${text}`; } }; diff --git a/src/sql/workbench/contrib/notebook/test/browser/notebookMarkdown.test.ts b/src/sql/workbench/contrib/notebook/test/browser/notebookMarkdown.test.ts index ad92a0f017..087b1908cb 100644 --- a/src/sql/workbench/contrib/notebook/test/browser/notebookMarkdown.test.ts +++ b/src/sql/workbench/contrib/notebook/test/browser/notebookMarkdown.test.ts @@ -69,6 +69,21 @@ suite('NotebookMarkdownRenderer', () => { assert.strict(markedPath, '

....\test.ipynb

'); }); + test('email in markdown format renders properly', () => { + let result: HTMLElement = notebookMarkdownRenderer.renderMarkdown({ value: `[test@email.com](mailto:test@email.com)`, isTrusted: true }); + assert.strictEqual(result.innerHTML, `

test@email.com

`); + }); + + test('email inserted directly renders properly', () => { + let result: HTMLElement = notebookMarkdownRenderer.renderMarkdown({ value: `test@email.com`, isTrusted: true }); + assert.strictEqual(result.innerHTML, `

test@email.com

`); + }); + + test('link to https with query parameters', () => { + let result: HTMLElement = notebookMarkdownRenderer.renderMarkdown({ value: `[test](https://www.test.com?test=&test2=)`, isTrusted: true }); + assert.strictEqual(result.innerHTML, `

test

`); + }); + test('cell attachment image', () => { let result: HTMLElement = notebookMarkdownRenderer.renderMarkdown({ value: `![altText](attachment:ads.png)`, isTrusted: true }, { cellAttachments: JSON.parse('{"ads.png":{"image/png":"iVBORw0KGgoAAAANSUhEUgAAAggg=="}}') }); assert.strictEqual(result.innerHTML, `

altText

`, 'Cell attachment basic test failed when trusted');