提交记录修改desktop/linux/cage-desktop.c+4 −2看文件
| @@ -737,9 +737,11 @@ static void install_bridge(void) { | ||
| 737 | 737 | char *code = g_strdup_printf( |
| 738 | 738 | "(()=>{'use strict';window.cageLinuxBridgeInit='injected';if(window!==window.top||location.protocol!=='http:'||location.hostname!=='localhost'||location.port!=='%d')return;" |
| 739 | 739 | "window.cageLinuxBridgeInit='origin-valid';window.cageNativeIMEAvailable=true;try{" |
| 740 | 删除: "const transport=window.webkit.messageHandlers.cageTransport;const token=%s;" | |
| 740 | 新增: "const handlers=window.webkit.messageHandlers,transport=handlers.cageTransport;const token=%s;" | |
| 741 | 741 | "const cage=Object.freeze({postMessage(request){return transport.postMessage({token,request});}});" |
| 742 | 删除: "Object.defineProperty(window.webkit.messageHandlers,'cage',{value:cage,writable:false,configurable:false});" | |
| 742 | 新增: "Object.defineProperty(handlers,'cage',{value:cage,writable:false,configurable:false});" | |
| 743 | 新增: /* Keep the WebKit wrapper alive for this document so its custom cage property survives GC. */ | |
| 744 | 新增: "Object.defineProperty(window,'cageLinuxMessageHandlers',{value:handlers});" | |
| 743 | 745 | "window.cageLinuxBridgeInit='ready';}catch(error){window.cageLinuxBridgeInit=error.name;}" |
| 744 | 746 | "})();", app.port, token); |
| 745 | 747 | /* The host allowlist narrows injection; the script and native receiver |

