fix 235221: Passing the markdown content to the webview via meta tag and purifying it before use

This commit is contained in:
Parasaran
2024-12-17 22:57:12 +05:30
parent 68410e1431
commit da1d8b9c8e
2 changed files with 8 additions and 2 deletions

View File

@@ -98,13 +98,13 @@ export class MdDocumentRenderer {
<meta id="vscode-markdown-preview-data"
data-settings="${escapeAttribute(JSON.stringify(initialData))}"
data-strings="${escapeAttribute(JSON.stringify(previewStrings))}"
data-state="${escapeAttribute(JSON.stringify(state || {}))}">
data-state="${escapeAttribute(JSON.stringify(state || {}))}"
data-md-content="${escapeAttribute(JSON.stringify(body.html))}">
<script src="${this._extensionResourcePath(resourceProvider, 'pre.js')}" nonce="${nonce}"></script>
${this._getStyles(resourceProvider, sourceUri, config, imageInfo)}
<base href="${resourceProvider.asWebviewUri(markdownDocument.uri)}">
</head>
<body class="vscode-body ${config.scrollBeyondLastLine ? 'scrollBeyondLastLine' : ''} ${config.wordWrap ? 'wordWrap' : ''} ${config.markEditorSelection ? 'showEditorSelection' : ''}">
${body.html}
${this._getScripts(resourceProvider, nonce)}
</body>
</html>`;