Merge pull request '漏洞' (#590) from Eeeros/forgeplus-react:pre_dev_military into pre_dev_military

This commit is contained in:
Eeeros 2023-10-18 14:34:55 +08:00
commit 9dd9b343aa
3 changed files with 7 additions and 6 deletions

View File

@ -32,7 +32,7 @@ function openTerminal(options) {
console.log(data);
client.sendClientData(data);
window.parent.postMessage({ tp: 'sshWorking' }, "*");
window.parent.postMessage({ tp: 'sshWorking' }, window.location.origin);
});
term.open();
$('body>.terminal').detach().appendTo(parentDomId + ' #term');
@ -66,6 +66,7 @@ function openTerminal(options) {
};
window.addEventListener("message", function (event) {
if (event.origin !== window.location.origin) return
console.log("post message: ");
console.log(event.data);
if (event.data.tp === 'resize') {
@ -106,7 +107,7 @@ function openTerminal(options) {
}
if (force_close_socket === false) {
// $(window).trigger('setSSHConnectStatus');
window.parent.postMessage({ tp: 'setSSHConnectStatus', tab: options.tab }, "*");
window.parent.postMessage({ tp: 'setSSHConnectStatus', tab: options.tab }, window.location.origin);
} else {
// 主动关闭连接时,不自动重连
force_close_socket = false;

View File

@ -111,7 +111,7 @@ function JupyterTPI (props) {
const addEventListeners = () => {
window.addEventListener('message', (e) => {
// console.log("触发了jupytermessage");
if(e){
if(e && e.origin === window.location.origin){
if(e.data){
if(e.data==="jupytermessage"){
newHandle()
@ -127,9 +127,9 @@ function JupyterTPI (props) {
return;
}
if(sum===1){
_iframe.contentWindow.postMessage("stopParent", "*");
_iframe.contentWindow.postMessage("stopParent", window.location.origin);
}else{
_iframe.contentWindow.postMessage("clonsParent", "*");
_iframe.contentWindow.postMessage("clonsParent", window.location.origin);
}
}

View File

@ -197,7 +197,7 @@ class Challengesjupyter extends Component {
window.addEventListener('message', (e) => {
if(e){
if(e && e.origin === window.location.origin){
if(e.data){
if(e.data==="jupytermessage"){
if(this.state.showtime===false){