handle quote escaping by stringifier instead manual handling

This commit is contained in:
pavlov3317 2019-03-09 17:33:55 +05:00
parent e266152342
commit 48afea0bd1

View File

@ -104,8 +104,8 @@ if(!glob[PROCESS_EVENT]){
}
function passEventToBrowser(browser: Browser, data: Event, ignoreNotFound: boolean): void {
const raw = util.stringifyData(data).replace(/'/g, "\\'");
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"}');`} }`);
const raw = util.stringifyData(data)
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> {