fix 235221: Encode and decode markdown content to escape illegal chars

pull/236145/head
Parasaran 2024-12-17 23:32:42 +05:30
parent da1d8b9c8e
commit ca72122751
2 changed files with 5 additions and 2 deletions

View File

@ -355,7 +355,10 @@ document.addEventListener('click', event => {
window.addEventListener('load', () => {
const htmlParser = new DOMParser();
const markDownHtml = htmlParser.parseFromString(getData('data-md-content'), 'text/html');
const markDownHtml = htmlParser.parseFromString(
decodeURIComponent(getData('data-md-content')),
'text/html'
);
document.body.appendChild(markDownHtml.body);
});

View File

@ -99,7 +99,7 @@ export class MdDocumentRenderer {
data-settings="${escapeAttribute(JSON.stringify(initialData))}"
data-strings="${escapeAttribute(JSON.stringify(previewStrings))}"
data-state="${escapeAttribute(JSON.stringify(state || {}))}"
data-md-content="${escapeAttribute(JSON.stringify(body.html))}">
data-md-content="${escapeAttribute(JSON.stringify(encodeURIComponent(body.html)))}">
<script src="${this._extensionResourcePath(resourceProvider, 'pre.js')}" nonce="${nonce}"></script>
${this._getStyles(resourceProvider, sourceUri, config, imageInfo)}
<base href="${resourceProvider.asWebviewUri(markdownDocument.uri)}">