提交 895f03e8 编写于 作者: M Matt Bierner

Encode webview state when injecting it into the webview

Fixes #101321

This should make sure we handle cases where the state string contains special characters, such as `<`
上级 06c3abf9
......@@ -135,13 +135,14 @@
* @return {string}
*/
function getVsCodeApiScript(allowMultipleAPIAcquire, state) {
const encodedState = state ? encodeURIComponent(JSON.stringify(state)) : undefined;
return `
const acquireVsCodeApi = (function() {
const originalPostMessage = window.parent.postMessage.bind(window.parent);
const targetOrigin = '*';
let acquired = false;
let state = ${state ? `JSON.parse(${JSON.stringify(state)})` : undefined};
let state = ${state ? `JSON.parse(decodeURIComponent("${encodedState}"))` : undefined};
return () => {
if (acquired && !${allowMultipleAPIAcquire}) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册