Merge pull request #169 from openHPI/edge-compat

Edge compat
This commit is contained in:
rteusner
2018-05-16 14:59:13 +02:00
committed by GitHub
5 changed files with 13 additions and 8 deletions

View File

@ -552,6 +552,10 @@ configureEditors: function () {
}, },
showWebsocketError: function() { showWebsocketError: function() {
if (window.navigator.userAgent.indexOf('Edge') > -1) {
// Mute errors in Microsoft Edge
return;
}
$.flash.danger({ $.flash.danger({
text: $('#flash').data('message-failure') text: $('#flash').data('message-failure')
}); });

View File

@ -4,10 +4,11 @@ CodeOceanEditorWebsocket = {
createSocketUrl: function(url) { createSocketUrl: function(url) {
var sockURL = new URL(window.location); var sockURL = new URL(window.location);
sockURL.pathname = url; sockURL.pathname = url;
sockURL.protocol = '<%= DockerClient.config['ws_client_protocol'] %>'; // 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 // strip anchor if it is in the url
sockURL.hash = '' sockURL.hash = '';
return sockURL.toString(); return sockURL.toString();
}, },

View File

@ -108,5 +108,5 @@ CommandSocket.prototype.flush = function() {
*/ */
CommandSocket.prototype.killWebSocket = function() { CommandSocket.prototype.killWebSocket = function() {
this.websocket.flush(); this.websocket.flush();
this.websocket.close(); this.websocket.close(1000);
}; };

View File

@ -9,7 +9,7 @@ development:
<<: *default <<: *default
host: tcp://127.0.0.1:2376 host: tcp://127.0.0.1:2376
ws_host: ws://127.0.0.1:2376 #url to connect rails server to docker host 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) %> workspace_root: <%= Rails.root.join('tmp', 'files', Rails.env) %>
pool: pool:
active: true active: true
@ -32,7 +32,7 @@ production:
timeout: 60 timeout: 60
workspace_root: <%= Rails.root.join('tmp', 'files', Rails.env) %> workspace_root: <%= Rails.root.join('tmp', 'files', Rails.env) %>
ws_host: ws://localhost:4243 #url to connect rails server to docker host 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: staging:
<<: *default <<: *default

View File

@ -9,7 +9,7 @@ development:
<<: *default <<: *default
host: tcp://127.0.0.1:2376 host: tcp://127.0.0.1:2376
ws_host: ws://127.0.0.1:2376 #url to connect rails server to docker host 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) %> workspace_root: <%= Rails.root.join('tmp', 'files', Rails.env) %>
pool: pool:
active: true active: true
@ -32,7 +32,7 @@ production:
timeout: 60 timeout: 60
workspace_root: <%= Rails.root.join('tmp', 'files', Rails.env) %> workspace_root: <%= Rails.root.join('tmp', 'files', Rails.env) %>
ws_host: ws://localhost:4243 #url to connect rails server to docker host 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: staging:
<<: *default <<: *default