From 538ae9cdc5cbe7a4790e277ba39d5bd04b265c22 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 9 Aug 2006 15:30:50 +0000 Subject: [PATCH] setting secure on xul calls by default git-svn-id: svn://svn.open-ils.org/ILS/trunk@5404 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/common/js/RemoteRequest.js | 19 ++++++++++--------- Open-ILS/web/opac/common/js/opac_utils.js | 5 +++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Open-ILS/web/opac/common/js/RemoteRequest.js b/Open-ILS/web/opac/common/js/RemoteRequest.js index c43257ede2..e289081e58 100644 --- a/Open-ILS/web/opac/common/js/RemoteRequest.js +++ b/Open-ILS/web/opac/common/js/RemoteRequest.js @@ -78,6 +78,9 @@ function RemoteRequest( service, method ) { this.id = service + method + Math.random(); this.cancelled = false; + this.setSecure(false); + if(isXUL()) this.setSecure(true); + _allrequests[this.id] = this; var i = 2; @@ -218,26 +221,24 @@ RemoteRequest.prototype.send = function(blocking) { /* determine the xmlhttp server dynamically */ var url = location.protocol + "//" + location.host + "/" + XML_HTTP_GATEWAY; - if(isXUL() && XML_HTTP_SERVER) { - if(this.secure || url.match(/^https:/) ) - url = "https://" + XML_HTTP_SERVER + "/" + XML_HTTP_GATEWAY; - else - url = "http://" + XML_HTTP_SERVER + "/" + XML_HTTP_GATEWAY; + if(isXUL()) { + netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); + if( this.secure ) url = url.replace(/http/, 'https'); + else url = url.replace(/https/, 'http'); } - /* this number could be a lot higher.. */ - var whole = url + this.param_string + 1; - var data = null; if( this.type == 'GET' ) url += "?" + this.param_string; + if(isXUL() && this.secure ) dump('SECURE = true\n'); + try { if(blocking) this.xmlhttp.open(this.type, url, false); else this.xmlhttp.open(this.type, url, true); } catch(E) { - alert("Fatal error opening XMLHTTPRequest for URL:\n" + url + '\n'); + alert("Fatal error opening XMLHTTPRequest for URL:\n" + url + '\n' + E); return; } diff --git a/Open-ILS/web/opac/common/js/opac_utils.js b/Open-ILS/web/opac/common/js/opac_utils.js index a41231f589..37dfefbeb2 100644 --- a/Open-ILS/web/opac/common/js/opac_utils.js +++ b/Open-ILS/web/opac/common/js/opac_utils.js @@ -15,6 +15,11 @@ function Request(type) { this.request = new RemoteRequest(s[0], s[1]); var p = []; + if(isXUL()) { + if(!location.href.match(/https:\/\//)) + this.request.setSecure(false); + } + for( var x = 1; x!= arguments.length; x++ ) { p.push(arguments[x]); this.request.addParam(arguments[x]); -- 2.11.0