From: Wolfgang Bumiller Date: Tue, 26 May 2015 14:09:38 +0000 (+0200) Subject: work around ipv6 browser inconsistencies X-Git-Url: https://git.proxmox.com/?p=pve-manager.git;a=commitdiff_plain;h=aa0819a8a5a4dbc14621b4109c98e4098a395b51 work around ipv6 browser inconsistencies Browsers seem to disagree on whether window.location.hostname shouldinclude the brackets around an ipv6 address. Adding PVE.Utils.windowHostname() to always strip them away. --- diff --git a/www/manager/Utils.js b/www/manager/Utils.js index 445237df..07cbd4db 100644 --- a/www/manager/Utils.js +++ b/www/manager/Utils.js @@ -44,6 +44,7 @@ var IPV6_REGEXP = "(?:" + var IP6_match = new RegExp("^(?:" + IPV6_REGEXP + ")$"); var IP6_cidr_match = new RegExp("^(?:" + IPV6_REGEXP + ")\/[0-9]{1,3}?$"); +var IP6_bracket_match = new RegExp("^\\[(" + IPV6_REGEXP + ")\\]"); var IP64_match = new RegExp("^(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + ")$"); @@ -920,6 +921,11 @@ Ext.define('PVE.Utils', { statics: { return gettext('Edit') + ': ' + subject; } }, + + windowHostname: function() { + return window.location.hostname.replace(IP6_bracket_match, + function(m, addr, offset, original) { return addr; }); + }, openDefaultConsoleWindow: function(allowSpice, vmtype, vmid, nodename, vmname) { var dv = PVE.Utils.defaultViewer(allowSpice); @@ -941,7 +947,7 @@ Ext.define('PVE.Utils', { statics: { PVE.Utils.openVNCViewer(vmtype, vmid, nodename, vmname, viewer === 'html5'); } else if (viewer === 'vv') { var url; - var params = { proxy: window.location.hostname }; + var params = { proxy: PVE.Utils.windowHostname() }; if (vmtype === 'kvm') { url = '/nodes/' + nodename + '/qemu/' + vmid.toString() + '/spiceproxy'; PVE.Utils.openSpiceViewer(url, params); diff --git a/www/manager5/Utils.js b/www/manager5/Utils.js index ee00bce8..7a2edc75 100644 --- a/www/manager5/Utils.js +++ b/www/manager5/Utils.js @@ -45,6 +45,7 @@ var IPV6_REGEXP = "(?:" + var IP6_match = new RegExp("^(?:" + IPV6_REGEXP + ")$"); var IP6_cidr_match = new RegExp("^(?:" + IPV6_REGEXP + ")\/[0-9]{1,3}?$"); +var IP6_bracket_match = new RegExp("^\\[(" + IPV6_REGEXP + ")\\]"); var IP64_match = new RegExp("^(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + ")$"); @@ -921,6 +922,11 @@ Ext.define('PVE.Utils', { statics: { return gettext('Edit') + ': ' + subject; } }, + + windowHostname: function() { + return window.location.hostname.replace(IP6_bracket_match, + function(m, addr, offset, original) { return addr; }); + }, openDefaultConsoleWindow: function(allowSpice, vmtype, vmid, nodename, vmname) { var dv = PVE.Utils.defaultViewer(allowSpice); @@ -942,7 +948,7 @@ Ext.define('PVE.Utils', { statics: { PVE.Utils.openVNCViewer(vmtype, vmid, nodename, vmname, viewer === 'html5'); } else if (viewer === 'vv') { var url; - var params = { proxy: window.location.hostname }; + var params = { proxy: PVE.Utils.windowHostname() }; if (vmtype === 'kvm') { url = '/nodes/' + nodename + '/qemu/' + vmid.toString() + '/spiceproxy'; PVE.Utils.openSpiceViewer(url, params);