handle quote escaping by stringifier instead manual handling
This commit is contained in:
parent
e266152342
commit
48afea0bd1
@ -104,8 +104,8 @@ if(!glob[PROCESS_EVENT]){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function passEventToBrowser(browser: Browser, data: Event, ignoreNotFound: boolean): void {
|
function passEventToBrowser(browser: Browser, data: Event, ignoreNotFound: boolean): void {
|
||||||
const raw = util.stringifyData(data).replace(/'/g, "\\'");
|
const raw = util.stringifyData(data)
|
||||||
browser.execute(`var process = window["${PROCESS_EVENT}"]; if(process){ process('${raw}'); }else{ ${ignoreNotFound ? '' : `mp.trigger("${PROCESS_EVENT}", '{"ret":1,"id":"${data.id}","err":"${ERR_NOT_FOUND}","env":"cef"}');`} }`);
|
browser.execute(`var process = window["${PROCESS_EVENT}"]; if(process){ process(${JSON.stringify(raw)}); }else{ ${ignoreNotFound ? '' : `mp.trigger("${PROCESS_EVENT}", '{"ret":1,"id":"${data.id}","err":"${ERR_NOT_FOUND}","env":"cef"}');`} }`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function callProcedure(name: string, args: any, info: ProcedureListenerInfo): Promise<any> {
|
function callProcedure(name: string, args: any, info: ProcedureListenerInfo): Promise<any> {
|
||||||
@ -321,4 +321,4 @@ export function callBrowser(browser: Browser, name: string, args?: any): Promise
|
|||||||
if(arguments.length !== 2 && arguments.length !== 3) return util.promiseReject('callBrowser expects 2 or 3 arguments: "browser", "name", and optional "args"');
|
if(arguments.length !== 2 && arguments.length !== 3) return util.promiseReject('callBrowser expects 2 or 3 arguments: "browser", "name", and optional "args"');
|
||||||
const id = util.uid();
|
const id = util.uid();
|
||||||
return _callBrowser(id, browser, name, args, {});
|
return _callBrowser(id, browser, name, args, {});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user