From 01dbb853bdcdee76a0f29f8999f6572b258cf420 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Mon, 30 Apr 2018 13:22:03 +0200 Subject: [PATCH 1/7] Use standardized protocol string for Edge/IE11 compatibility --- config/docker.yml.erb.example | 4 ++-- config/docker.yml.erb.travis | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/docker.yml.erb.example b/config/docker.yml.erb.example index eb1af61e..5d9f42de 100644 --- a/config/docker.yml.erb.example +++ b/config/docker.yml.erb.example @@ -9,7 +9,7 @@ development: <<: *default host: tcp://127.0.0.1:2376 ws_host: ws://127.0.0.1:2376 #url to connect rails server to docker host - ws_client_protocol: ws:// #set the websocket protocol to be used by the client to connect to the rails server (ws on development, wss on production) + ws_client_protocol: 'ws:' #set the websocket protocol to be used by the client to connect to the rails server (ws on development, wss on production) workspace_root: <%= Rails.root.join('tmp', 'files', Rails.env) %> pool: active: true @@ -32,7 +32,7 @@ production: timeout: 60 workspace_root: <%= Rails.root.join('tmp', 'files', Rails.env) %> ws_host: ws://localhost:4243 #url to connect rails server to docker host - ws_client_protocol: wss:// #set the websocket protocol to be used by the client to connect to the rails server (ws on development, wss on production) + ws_client_protocol: 'wss:' #set the websocket protocol to be used by the client to connect to the rails server (ws on development, wss on production) staging: <<: *default diff --git a/config/docker.yml.erb.travis b/config/docker.yml.erb.travis index eb1af61e..5d9f42de 100644 --- a/config/docker.yml.erb.travis +++ b/config/docker.yml.erb.travis @@ -9,7 +9,7 @@ development: <<: *default host: tcp://127.0.0.1:2376 ws_host: ws://127.0.0.1:2376 #url to connect rails server to docker host - ws_client_protocol: ws:// #set the websocket protocol to be used by the client to connect to the rails server (ws on development, wss on production) + ws_client_protocol: 'ws:' #set the websocket protocol to be used by the client to connect to the rails server (ws on development, wss on production) workspace_root: <%= Rails.root.join('tmp', 'files', Rails.env) %> pool: active: true @@ -32,7 +32,7 @@ production: timeout: 60 workspace_root: <%= Rails.root.join('tmp', 'files', Rails.env) %> ws_host: ws://localhost:4243 #url to connect rails server to docker host - ws_client_protocol: wss:// #set the websocket protocol to be used by the client to connect to the rails server (ws on development, wss on production) + ws_client_protocol: 'wss:' #set the websocket protocol to be used by the client to connect to the rails server (ws on development, wss on production) staging: <<: *default From 4440acec100b51f9515096c4161677d3fa060a7e Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Mon, 7 May 2018 16:38:26 +0200 Subject: [PATCH 2/7] Ensure no malformed protocol definition --- app/assets/javascripts/editor/execution.js.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/editor/execution.js.erb b/app/assets/javascripts/editor/execution.js.erb index 5d50e69d..63f4ce32 100644 --- a/app/assets/javascripts/editor/execution.js.erb +++ b/app/assets/javascripts/editor/execution.js.erb @@ -4,7 +4,7 @@ CodeOceanEditorWebsocket = { createSocketUrl: function(url) { var sockURL = new URL(window.location); sockURL.pathname = url; - sockURL.protocol = '<%= DockerClient.config['ws_client_protocol'] %>'; + sockURL.protocol = '<%= DockerClient.config['ws_client_protocol'].match(/(\w+):*\/*/)&.to_a&.at(1) %>:' // strip anchor if it is in the url sockURL.hash = '' From bedaec76a8dba2d1d9bb434f42099ba24c99d1fa Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Mon, 7 May 2018 16:40:22 +0200 Subject: [PATCH 3/7] Add missing semicolons --- app/assets/javascripts/editor/execution.js.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/editor/execution.js.erb b/app/assets/javascripts/editor/execution.js.erb index 63f4ce32..ba432582 100644 --- a/app/assets/javascripts/editor/execution.js.erb +++ b/app/assets/javascripts/editor/execution.js.erb @@ -4,10 +4,10 @@ CodeOceanEditorWebsocket = { createSocketUrl: function(url) { var sockURL = new URL(window.location); sockURL.pathname = url; - sockURL.protocol = '<%= DockerClient.config['ws_client_protocol'].match(/(\w+):*\/*/)&.to_a&.at(1) %>:' + sockURL.protocol = '<%= DockerClient.config['ws_client_protocol'].match(/(\w+):*\/*/)&.to_a&.at(1) %>:'; // strip anchor if it is in the url - sockURL.hash = '' + sockURL.hash = ''; return sockURL.toString(); }, From 8faab600b5dd450d1aea40a7e813453d51645047 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Mon, 7 May 2018 17:25:42 +0200 Subject: [PATCH 4/7] Fix nil config resulting in failing tests --- app/assets/javascripts/editor/execution.js.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/editor/execution.js.erb b/app/assets/javascripts/editor/execution.js.erb index ba432582..32035828 100644 --- a/app/assets/javascripts/editor/execution.js.erb +++ b/app/assets/javascripts/editor/execution.js.erb @@ -4,7 +4,7 @@ CodeOceanEditorWebsocket = { createSocketUrl: function(url) { var sockURL = new URL(window.location); sockURL.pathname = url; - sockURL.protocol = '<%= DockerClient.config['ws_client_protocol'].match(/(\w+):*\/*/)&.to_a&.at(1) %>:'; + sockURL.protocol = '<%= DockerClient.config['ws_client_protocol']&.match(/(\w+):*\/*/)&.to_a&.at(1) %>:'; // strip anchor if it is in the url sockURL.hash = ''; From a92c13ed719f82c1b5dccbce5dd5e7f5e997cbe3 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Wed, 16 May 2018 14:35:08 +0200 Subject: [PATCH 5/7] Mute "unknown error" messages in Edge which occur after the socket was closed successfully --- app/assets/javascripts/editor/editor.js.erb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/javascripts/editor/editor.js.erb b/app/assets/javascripts/editor/editor.js.erb index e16d37a7..00ce3fc7 100644 --- a/app/assets/javascripts/editor/editor.js.erb +++ b/app/assets/javascripts/editor/editor.js.erb @@ -552,6 +552,10 @@ configureEditors: function () { }, showWebsocketError: function() { + if (window.navigator.userAgent.indexOf('Edge') > -1) { + // Mute errors in Microsoft Edge + return; + } $.flash.danger({ text: $('#flash').data('message-failure') }); From e4525bca361d65a7af3e2b8c8194026bb1f51fd5 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Wed, 16 May 2018 14:37:13 +0200 Subject: [PATCH 6/7] Cleanly close websocket --- app/assets/javascripts/editor/websocket.js.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/editor/websocket.js.erb b/app/assets/javascripts/editor/websocket.js.erb index baba623d..1d0e2b25 100644 --- a/app/assets/javascripts/editor/websocket.js.erb +++ b/app/assets/javascripts/editor/websocket.js.erb @@ -108,5 +108,5 @@ CommandSocket.prototype.flush = function() { */ CommandSocket.prototype.killWebSocket = function() { this.websocket.flush(); - this.websocket.close(); -}; \ No newline at end of file + this.websocket.close(1000); +}; From cb56a21951921ed02649d0a1f96e681c31d0c771 Mon Sep 17 00:00:00 2001 From: rteusner Date: Wed, 16 May 2018 14:41:15 +0200 Subject: [PATCH 7/7] Update execution.js.erb --- app/assets/javascripts/editor/execution.js.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/editor/execution.js.erb b/app/assets/javascripts/editor/execution.js.erb index 32035828..a5126462 100644 --- a/app/assets/javascripts/editor/execution.js.erb +++ b/app/assets/javascripts/editor/execution.js.erb @@ -4,6 +4,7 @@ CodeOceanEditorWebsocket = { createSocketUrl: function(url) { var sockURL = new URL(window.location); sockURL.pathname = url; + // sanitize socket protocol string, strip trailing slash and other malicious chars if they are there sockURL.protocol = '<%= DockerClient.config['ws_client_protocol']&.match(/(\w+):*\/*/)&.to_a&.at(1) %>:'; // strip anchor if it is in the url